rxjs/operators#expand TypeScript Examples

The following examples show how to use rxjs/operators#expand. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: dependent-intentions.component.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 6 votes vote down vote up
constructor(manifestService: DevToolsManifestService, private _router: Router) {
    this.intentionsByApp$ = this._appChange$
      .pipe(
        switchMap(() => manifestService.observeDependentIntentions$(this.appSymbolicName)),
        expand(intentions => this.filterFormControl.valueChanges.pipe(take(1), map(() => intentions))),
        map(intentions => filterManifestObjects(intentions, this.filterFormControl.value)),
        map(intentions => intentions.reduce((acc, intention) => Maps.addListValue(acc, intention.metadata.appSymbolicName, intention), new Map())),
      );
  }
Example #2
Source File: required-capabilities.component.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 6 votes vote down vote up
constructor(manifestService: DevToolsManifestService, private _router: Router) {
    this.capabilitiesByApp$ = this._appChange$
      .pipe(
        switchMap(() => manifestService.observeDependingCapabilities$(this.appSymbolicName)),
        expand(capabilities => this.filterFormControl.valueChanges.pipe(take(1), map(() => capabilities))),
        map(capabilities => filterManifestObjects(capabilities, this.filterFormControl.value)),
        map(capabilities => capabilities.reduce((acc, capability) => Maps.addListValue(acc, capability.metadata.appSymbolicName, capability), new Map())),
      );
  }
Example #3
Source File: ɵmanifest-registry.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 6 votes vote down vote up
private installCapabilitiesLookupRequestHandler(): void {
    Beans.get(MessageClient).observe$<ManifestObjectFilter>(ManifestRegistryTopics.LookupCapabilities)
      .pipe(takeUntil(this._destroy$))
      .subscribe((request: TopicMessage<ManifestObjectFilter>) => runSafe(() => {
        const replyTo = request.headers.get(MessageHeaders.ReplyTo);
        const appSymbolicName = request.headers.get(MessageHeaders.AppSymbolicName);
        const lookupFilter = request.body || {};

        // The queried capabilities may change on both, capability or intention change, because the computation
        // of visible and qualified capabilities depends on registered capabilities and manifested intentions.
        const registryChange$ = merge(this._capabilityStore.change$, this._intentionStore.change$);
        const finder$ = defer(() => of(this._capabilityStore.find(lookupFilter)));
        return finder$
          .pipe(
            expand(() => registryChange$.pipe(take(1), mergeMap(() => finder$))),
            filterArray(capability => this.isApplicationQualifiedForCapability(appSymbolicName, capability)),
            distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)),
            takeUntilUnsubscribe(replyTo),
          )
          .subscribe(capabilities => { // eslint-disable-line rxjs/no-nested-subscribe
            Beans.get(MessageClient).publish<Capability[]>(replyTo, capabilities, {headers: new Map().set(MessageHeaders.Status, ResponseStatusCodes.OK)});
          });
      }));
  }
Example #4
Source File: ɵmanifest-registry.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 6 votes vote down vote up
private installIntentionsLookupRequestHandler(): void {
    Beans.get(MessageClient).observe$<ManifestObjectFilter>(ManifestRegistryTopics.LookupIntentions)
      .pipe(takeUntil(this._destroy$))
      .subscribe((request: TopicMessage<ManifestObjectFilter>) => runSafe(() => {
        const replyTo = request.headers.get(MessageHeaders.ReplyTo);
        const lookupFilter = request.body || {};

        const finder$ = defer(() => of(this._intentionStore.find(lookupFilter)));
        return finder$
          .pipe(
            expand(() => this._intentionStore.change$.pipe(take(1), mergeMap(() => finder$))),
            distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)),
            takeUntilUnsubscribe(replyTo),
          )
          .subscribe(intentions => { // eslint-disable-line rxjs/no-nested-subscribe
            Beans.get(MessageClient).publish<Intention[]>(replyTo, intentions, {headers: new Map().set(MessageHeaders.Status, ResponseStatusCodes.OK)});
          });
      }));
  }
Example #5
Source File: app-details.component.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 5 votes vote down vote up
private observeCapabilities$(): Observable<Capability[]> {
    return this.application$
      .pipe(
        switchMap(application => this._manifestService.capabilities$({appSymbolicName: application.symbolicName})),
        expand(capabilities => this.capabilityFilterFormControl.valueChanges.pipe(take(1), map(() => capabilities))),
        map(capabilities => filterManifestObjects(capabilities, this.capabilityFilterFormControl.value)),
      );
  }
Example #6
Source File: app-details.component.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 5 votes vote down vote up
private observeIntentions$(): Observable<Intention[]> {
    return this.application$
      .pipe(
        switchMap(application => this._manifestService.intentions$({appSymbolicName: application.symbolicName})),
        expand(intentions => this.intentionFilterFormControl.valueChanges.pipe(take(1), map(() => intentions))),
        map(intentions => filterManifestObjects(intentions, this.intentionFilterFormControl.value)),
      );
  }
Example #7
Source File: capability-filter-result.component.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 5 votes vote down vote up
constructor(shellService: ShellService, capabilityFilterSession: CapabilityFilterSession) {
    shellService.detailsTitle = 'Capabilities';
    this.capabilities$ = capabilityFilterSession.capabilities$()
      .pipe(
        expand(capabilities => this.filterFormControl.valueChanges.pipe(take(1), map(() => capabilities))),
        map(capabilities => filterManifestObjects(capabilities, this.filterFormControl.value)),
      );
  }
Example #8
Source File: capability-filter-session.service.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 5 votes vote down vote up
public capabilities$(): Observable<Capability[]> {
    return this._manifestService.capabilities$()
      .pipe(
        expand(capabilities => this._filterChange$.pipe(take(1), map(() => capabilities))),
        map(capabilities => this.filter(capabilities)),
      );
  }