angular2-http-event

1.0.0 • Public • Published

angular2-http-event

simple events center for angular2 http module

Usage

1. add decorator httpEmitter to http method

import { httpEmitter } from '/path/to/http-event.service';
 
class demoHttpService() {
  constructor(private http: Http) {}
  
  @httpEmitter
  query(args) {
    return this.http.get().map(response => response.json());
  }
}

now this method will emit 'START' and 'FINISH' events.

2. subscribe to http event

import { HttpEventService } from '/path/to/http-event.service';
 
@Component({...})
class DemoComponent implements OnInit {
  constructor(private httpEvent: HttpEventService) {}
  
  ngOnInit() {
    this.httpEvent.httpEventCenter.subscribe((type: HttpEventType) => {
      // event handler here...
    });
  }
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    1

Package Sidebar

Install

npm i angular2-http-event

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • gucheen