* Tell your in-mem "database" to reset. * returns Observable of the database because resetting it could be async
(reqInfo?: RequestInfo)
| 721 | * returns Observable of the database because resetting it could be async |
| 722 | */ |
| 723 | protected resetDb(reqInfo?: RequestInfo): Observable<boolean> { |
| 724 | this.dbReadySubject && this.dbReadySubject.next(false); |
| 725 | const db = this.inMemDbService.createDb(reqInfo); |
| 726 | const db$ = |
| 727 | db instanceof Observable |
| 728 | ? db |
| 729 | : typeof (db as any).then === 'function' |
| 730 | ? from(db as Promise<any>) |
| 731 | : of(db); |
| 732 | db$.pipe(first()).subscribe((d: {}) => { |
| 733 | this.db = d; |
| 734 | this.dbReadySubject && this.dbReadySubject.next(true); |
| 735 | }); |
| 736 | return this.dbReady; |
| 737 | } |
| 738 | } |