Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private _nationalProps: BehaviorSubject<NationalProp[]> = new BehaviorSubject<NationalProp[]>([]);
- get national() {
- return this._nationalProps.pipe(take(1), map(nprops => {
- return [...nprops];
- })
- );
- deleteNationalProp(id: string) {
- return this.http.delete(this.serverUrl + `/national_props/${id}.json`)
- .pipe(
- switchMap(() => {
- return this._nationalProps;
- }),
- take(1),
- tap(props => {
- this._nationalProps.next(props.filter(b => b.id !== id));
- }));
- }
- propSub: Subscription; // imported from rxjs
- loadedProps: NationalProp[];
- ngOnInit() {
- this.propSub = this.servicesSrv.national.subscribe(props => {
- this.loadedProps = props;
- });
- this.servicesSrv.deleteNationalProp(pId).subscribe();
- get national() {
- return this._nationalProps.pipe(map(nprops => {
- return [...nprops];
- })
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement