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...
        });
      }
    }

    Install

    npm i angular2-http-event

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • gucheen