SHARE
TWEET

Untitled

a guest Jul 18th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private _nationalProps: BehaviorSubject<NationalProp[]> = new BehaviorSubject<NationalProp[]>([]);
  2.      
  3. get national() {
  4.     return this._nationalProps.pipe(take(1), map(nprops => {
  5.       return [...nprops];
  6.     })
  7.     );
  8.      
  9. deleteNationalProp(id: string) {
  10.     return this.http.delete(this.serverUrl + `/national_props/${id}.json`)
  11.           .pipe(
  12.           switchMap(() => {
  13.             return this._nationalProps;
  14.           }),
  15.           take(1),
  16.           tap(props => {
  17.       this._nationalProps.next(props.filter(b => b.id !== id));
  18.     }));
  19.   }
  20.      
  21. propSub: Subscription; // imported from rxjs
  22. loadedProps: NationalProp[];
  23.  
  24. ngOnInit() {
  25.  this.propSub = this.servicesSrv.national.subscribe(props => {
  26.       this.loadedProps = props;
  27.     });
  28.      
  29. this.servicesSrv.deleteNationalProp(pId).subscribe();
  30.      
  31. get national() {
  32.     return this._nationalProps.pipe(map(nprops => {
  33.       return [...nprops];
  34.     })
  35.     );
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top