Skip to content

Instantly share code, notes, and snippets.

@chrillewoodz
Created July 27, 2017 15:27
Show Gist options
  • Save chrillewoodz/e41eec55ecb7767d72af73309d482f35 to your computer and use it in GitHub Desktop.
Save chrillewoodz/e41eec55ecb7767d72af73309d482f35 to your computer and use it in GitHub Desktop.
import {Injectable} from '@angular/core';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
@Injectable()
export class ModalApi {
private states = new BehaviorSubject<any>(true);
public states$ = this.states.asObservable();
constructor() {}
open(id: string, template?: string): Promise<any> {
this.states.next({isOpen: true, id: id, template: template});
return new Promise((resolve, reject) => {
resolve({id: id, template: template});
});
}
close(id: string): Promise<any> {
this.states.next({isOpen: false, id: id});
return new Promise((resolve, reject) => {
resolve({id: id});
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment