requirements.map(node => { if (typeof node === "string") { if (node.startsWith("subprograms")) { // Resolve the subprogram. return publishDocument( this.subprogramsRef.doc(node.split("/")[1]) ).pipe( switchMap(result => { if (!result) { console.error("Could not resolve subprogram: " + node); return of({ display: "Specification error" }); } return this.resolve(JSON.parse(result.requirements)).pipe( map(requirements => ({ display: result.display, requirements })) ); }) ); } else { return of(node); } } else if (node.requirements) { return this.resolve(node.requirements).pipe( map(requirements => ({ ...node, requirements })) ); } else { return of(node); } })
ngxsOnInit({ dispatch }: StateContext<ShopProductsModel>) { concat( this.stateService.getInitialState('', 'products').pipe(take(1)), /* LOGIN: */ this.store$.select(UserState.isLoggedIn).pipe( pairwise(), filter(([wasLoggedIn, isLoggedIn]) => !wasLoggedIn && isLoggedIn), switchMap(() => this.stateService.getInitialState('', 'products').pipe(take(1))) ) ).subscribe((products) => { dispatch(new InitShopProductsAction(products)); }); // Update products from server on entry update (name, attribute, instock, reservations) this.actions$.pipe( ofActionSuccessful(UpdateSectionEntryFromSyncAction), filter(action => { const actions = ['cartTitle', 'cartPrice', 'cartAttributes']; const prop = action.path.split('/').pop(); return actions.indexOf(prop) > -1; }), switchMap(() => this.stateService.getInitialState('', 'products', true).pipe(take(1))) ).subscribe((products) => { dispatch(new InitShopProductsAction(products)); }); }
test(`invoke "update" action`, (done) => { const playlist = new KalturaPlaylist({ name: "tstest.PlaylistTests.test_createRemote", referenceId: "tstest.PlaylistTests.test_update", playlistType: KalturaPlaylistType.staticList }); expect.assertions(1); kalturaClient.request(new PlaylistAddAction({playlist})) .pipe( switchMap(({id}) => { playlist.name = "Changed!"; return kalturaClient.request(new PlaylistUpdateAction({id, playlist})); } ), switchMap(({id, name}) => { asyncAssert(() => { expect(name).toBe("Changed!"); }); return kalturaClient.request(new PlaylistDeleteAction({id})); })) .subscribe(() => { done(); }, error => { done.fail(error); }); });
ngOnInit() { this.block$ = combineLatest( this.config.currentChain$, this.route.paramMap.pipe( switchMap(params => of(params.get('hash'))), filter((hash): hash is string => typeof hash === 'string') ) ).pipe( switchMap(([chain, hash]) => this.apiService.streamBlock(chain, hash)) ); }
const shortCachesResolve = ['ConfigSelectors', 'ConfigureState', 'ConfigEffects', '$transition$', function(ConfigSelectors, ConfigureState, {etp}, $transition$) { if ($transition$.params().clusterID === 'new') return Promise.resolve(); return from($transition$.injector().getAsync('_cluster')).pipe( switchMap(() => ConfigureState.state$.pipe(ConfigSelectors.selectCluster($transition$.params().clusterID), take(1))), switchMap((cluster) => { return etp('LOAD_SHORT_CACHES', {ids: cluster.caches, clusterID: cluster._id}); }) ) .toPromise(); }];
export function provideMigrations(area: chrome.storage.StorageArea): MigratableStorageArea { const migrations = new Subject<MigrateFunc>() const getCalls = new ReplaySubject<any[]>() const setCalls = new ReplaySubject<any[]>() const migrated = migrations.pipe( switchMap( migrate => new Observable(observer => { area.get(items => { const { newItems, keysToRemove } = migrate(items as StorageItems) area.remove(keysToRemove || [], () => { area.set(newItems || {}, () => { observer.next() observer.complete() }) }) }) }) ), take(1), share() ) const initializedGets = migrated.pipe(switchMap(() => getCalls)) const initializedSets = migrated.pipe(switchMap(() => setCalls)) initializedSets.subscribe(args => { area.set.apply(area, args) }) initializedGets.subscribe(args => { area.get.apply(area, args) }) const get: chrome.storage.StorageArea['get'] = (...args) => { getCalls.next(args) } const set: chrome.storage.StorageArea['set'] = (...args) => { setCalls.next(args) } return { ...area, get, set, setMigration: migrate => { migrations.next(migrate) }, } }
constructor(ref: DocumentReference) { this.ref = ref; this.index = new PackedIndex(); this.data().subscribe(data => this.index.setInstitution(data)); this.gradeDistribution = this.data().pipe( switchMap(data => Axios.get(`${data.cloudFunctionsUrl}/api/grades`)), map( (response: { data: any }) => Object.freeze(response.data) as Distribution ), publishReplay(1), refCount() ); this.courseRanking = combineLatest( this.getGradeDistribution().pipe( map(distribution => { return Object.entries(distribution).reduce((obj, [course, data]) => { return { ...obj, [course]: 2 * Object.values(data).reduce((a, b) => a + b, 0) }; }, {}); }) ), this.index.getSequences().pipe( switchMap(sequences => { return combineLatest( sequences.map(sequence => this.index.getSparseSequence(sequence)) ); }) ) ).pipe( map(([courseRanking, sparseSequences]) => { sparseSequences.forEach(sequence => { // Promote the rank of each course in the sequence to the max. const max = sequence .map(course => courseRanking[course] | 0) .reduce((a, b) => Math.max(a, b)) + 1; sequence.forEach(course => (courseRanking[course] = max)); }); return courseRanking; }), publishReplay(1), refCount() ); }
return new Observable<Path>(obs => { if (options.appModuleBundle) { obs.next(join(this.context.workspace.root, options.appModuleBundle)); return obs.complete(); } else { const [project, target, configuration] = options.serverTarget.split(':'); const builderConfig = architect.getBuilderConfiguration<BuildWebpackServerSchema>({ project, target, configuration, }); return architect.getBuilderDescription(builderConfig).pipe( concatMap(description => architect.validateBuilderOptions(builderConfig, description)), switchMap(config => { const outputPath = join(this.context.workspace.root, config.options.outputPath); return this.context.host.list(outputPath).pipe( switchMap(files => { const re = /^main\.(?:[a-zA-Z0-9]{20}\.)?(?:bundle\.)?js$/; const maybeMain = files.filter(x => re.test(x))[0]; if (!maybeMain) { return throwError(new Error('Could not find the main bundle.')); } else { return of(join(outputPath, maybeMain)); } }), ); }), ).subscribe(obs); } });
run(builderConfig: BuilderConfiguration<BuildWebpackAppShellSchema>): Observable<BuildEvent> { const options = builderConfig.options; return new Observable<BuildEvent>(obs => { let success = true; const subscription = merge( this.build(options.serverTarget, {}), // Never run the browser target in watch mode. // If service worker is needed, it will be added in this.renderUniversal(); this.build(options.browserTarget, { watch: false, serviceWorker: false }), ).subscribe((event: BuildEvent) => { // TODO: once we support a better build event, add support for merging two event streams // together. success = success && event.success; }, error => { obs.error(error); }, () => { obs.next({ success }); obs.complete(); }); // Allow subscriptions to us to unsubscribe from each builds at the same time. return () => subscription.unsubscribe(); }).pipe( switchMap(event => { if (!event.success) { return of(event); } return this.renderUniversal(options); }), ); }
openConfigureDialog() { const dialogSub = this.dialog.open(ConfigureComponent, { width: `1024px`, data: { chart$: this.chartDetails$, } }).afterClosed() .pipe( filter(values => values !== undefined), map( values => this.chartDetails$.pipe( map(chart => { chart.values = values; return chart; }) ) ), switchMap(values => values), tap((updatedValues) => { this.store.dispatch(new SetAppDetails(updatedValues)); }) ).subscribe(val => { console.log('res1', val); }); this.subscriptons.add(dialogSub); }