Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Component
- ngOnInit():void {
- this.service.getAsync();
- }
- Service
- private _subject = new BehaviorSubject<any>([]);
- subject$ = this._subject.asObservable();
- getAsync() {
- this.subject$ = this.http
- .post(url, payload, options)
- .map();
- }
- Component
- ngOnInit():void {
- this.service.setAsync();
- }
- Service
- private _subject = new BehaviorSubject<any>([]);
- subject$ = this._subject.asObservable();
- setAsync(){
- this.subject$ = this.getAsync();
- }
- getAsync(): Observable<any[]> {
- return this.http
- .post(url, payload, options)
- .map();
- }
- Component
- ngOnInit():void {
- this.service.getAsync();
- }
- Service
- private _subject = new BehaviorSubject<any>([]);
- subject$ = this._subject.asObservable();
- getAsync() {
- this.http
- .post(url, payload, options)
- .map(data => this._subject.next(data));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement