How to use rxjs-spy - 10 common examples

To help you get started, we’ve selected a few rxjs-spy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cloudfoundry / stratos / src / frontend / packages / core / src / shared / monitors / pagination-monitor.ts View on Github external
pagination$,
      schema
    );

    const allEntitiesObservable$ = this.store.select(getAPIRequestDataState);

    const entities$ = pagination$.pipe(
      distinctUntilChanged(),
      // Improve efficiency
      observeOn(asapScheduler),
      combineLatestOperator(entityObservable$),
      withLatestFrom(allEntitiesObservable$),
      map(([[pagination], allEntities]) => {
        return this.getLocalEntities(pagination, allEntities, schema).filter(ent => !!ent);
      }),
      tag('de-norming-local ' + schema.key),
    );

    const isMultiAction$ = combineLatest(
      pagination$,
      fetching$
    ).pipe(
      filter(([pagination, fetching]) => !fetching),
      map(([pagination]) => {
        return Object.values(pagination.pageRequests).reduce((entityKeys, pageRequest) => {
          const { entityConfig } = pageRequest;
          const key = entityCatalogue.getEntityKey(entityConfig);
          if (key && !entityKeys.includes(key)) {
            entityKeys.push(key);
          }
          return entityKeys;
        }, []).length > 1;
github jupyterlab / jupyterlab-data-explorer / dataregistry / src / converters.ts View on Github external
export function applyConverter$(
  datasets$: Datasets$,
  converter$: Observable>
): Datasets$ {
  return combineLatest(datasets$, converter$).pipe(
    tag("applyConverter$/zipped"),
    // Take latest output and merge with most recent
    scan(
      (acc: Datasets, [datasets, converter]) =>
        applyConverterDatasets(acc, datasets, converter),
      new Map()
    ),
    shareReplay({ bufferSize: 1, refCount: true }),
    tag("applyConverter$/scanned")
  );
}
github cloudfoundry / stratos / src / frontend / packages / core / src / shared / components / list / data-sources-controllers / list-pagination-controller.ts View on Github external
filter(pag => !!pag),
      map(pag => {
        const pageSize = (dataSource.isLocal ? pag.clientPagination.pageSize : pag.params['results-per-page'])
          || defaultClientPaginationPageSize;
        const pageIndex = (dataSource.isLocal ? pag.clientPagination.currentPage : pag.currentPage) || 1;
        // const totalResults = (dataSource.isLocal ? pag.clientPagination.totalResults : pag.totalResults) || 0;
        return {
          totalResults: pag.totalResults,
          pageSize,
          pageIndex
        };
      }),
      distinctUntilChanged((x, y) => {
        return x.pageIndex === y.pageIndex && x.pageSize === y.pageSize && x.totalResults === y.totalResults;
      }),
      tag('list-pagination')
    );
  }
github cloudfoundry / stratos / src / frontend / packages / core / src / shared / monitors / pagination-monitor.ts View on Github external
const entityObservable$ = this.store
      .select(selectEntities(schema.key))
      .pipe(distinctUntilChanged());
    const allEntitiesObservable$ = this.store.select(getAPIRequestDataState);
    return pagination$.pipe(
      // Improve efficiency
      observeOn(asapScheduler),
      filter(pagination => this.hasPage(pagination) && !LocalPaginationHelpers.isPaginationMaxed(pagination)),
      distinctUntilChanged(this.isPageSameIsh),
      combineLatestOperator(entityObservable$),
      withLatestFrom(allEntitiesObservable$),
      map(([[pagination], allEntities]) => {
        const { page, pageSchema } = this.getPageInfo(pagination, pagination.currentPage, schema);
        return this.denormalizePage(page, pageSchema, allEntities);
      }),
      tag('de-norming ' + schema.key),
      publishReplay(1),
      refCount(),
    );
  }
github cloudfoundry / stratos / src / frontend / packages / core / src / app / shared / monitors / pagination-monitor.ts View on Github external
.pipe(distinctUntilChanged());
    const allEntitiesObservable$ = this.store.select(getAPIRequestDataState);
    return pagination$.pipe(
      // Improve efficiency
      observeOn(asapScheduler),
      filter(pagination => this.hasPage(pagination)),
      distinctUntilChanged(this.isPageSameIsh),
      combineLatestOperator(entityObservable$),
      withLatestFrom(allEntitiesObservable$),
      map(([[pagination], allEntities]) => {
        const page = pagination.ids[pagination.currentPage] || [];
        return page.length
          ? denormalize(page, [schema], allEntities).filter(ent => !!ent)
          : [];
      }),
      tag('de-norming ' + schema.key),
      publishReplay(1),
      refCount(),
    );
  }
github cloudfoundry / stratos / src / frontend / packages / core / src / app / shared / components / list / data-sources-controllers / list-pagination-controller.ts View on Github external
filter(pag => !!pag),
      map(pag => {
        const pageSize = (dataSource.isLocal ? pag.clientPagination.pageSize : pag.params['results-per-page'])
          || defaultClientPaginationPageSize;
        const pageIndex = (dataSource.isLocal ? pag.clientPagination.currentPage : pag.currentPage) || 1;
        // const totalResults = (dataSource.isLocal ? pag.clientPagination.totalResults : pag.totalResults) || 0;
        return {
          totalResults: pag.totalResults,
          pageSize,
          pageIndex
        };
      }),
      distinctUntilChanged((x, y) => {
        return x.pageIndex === y.pageIndex && x.pageSize === y.pageSize && x.totalResults === y.totalResults;
      }),
      tag('list-pagination')
    );
  }
github cloudfoundry / stratos / src / frontend / app / app.component.ts View on Github external
constructor(
    private loggedInService: LoggedInService,
    ext: ExtensionManager,
  ) {
    if (!environment.production) {
      if (environment.showObsDebug || environment.disablePolling) {
        const spy = create();
        if (environment.showObsDebug) {
          // spy.log('entity-obs');
          // spy.log('entity-request-obs');
          spy.log('list-pagination');
          spy.log('list-sort');
          spy.log('local-list');
          spy.log('pageSubObs');
          spy.log('actual-page-obs');
          spy.log('stat-obs');
          // spy.log('list');
        }
        if (environment.disablePolling) {
          spy.pause('poll');
        }
      }
    }
github cloudfoundry / stratos / src / frontend / packages / core / src / app.component.ts View on Github external
constructor(
    private loggedInService: LoggedInService,
    store: Store
  ) {
    // We use the username to key the session storage. We could replace this with the users id?
    this.userId$ = store.select(state => state.auth.sessionData && state.auth.sessionData.user ? state.auth.sessionData.user.name : null);
    if (!environment.production) {
      if (environment.showObsDebug || environment.disablePolling) {
        const spy = create();
        if (environment.showObsDebug) {
          // spy.log('entity-obs');
          // spy.log('entity-request-obs');
          spy.log('list-pagination');
          spy.log('list-sort');
          spy.log('local-list');
          spy.log('pageSubObs');
          spy.log('actual-page-obs');
          spy.log('stat-obs');
          // spy.log('list');
        }
        if (environment.disablePolling) {
          spy.pause('poll');
        }
      }
    }
github cloudfoundry / stratos / src / frontend / packages / core / src / app.component.ts View on Github external
constructor(
    private loggedInService: LoggedInService,
    store: Store
  ) {
    // We use the username to key the session storage. We could replace this with the users id?
    this.userId$ = store.select(state => state.auth.sessionData && state.auth.sessionData.user ? state.auth.sessionData.user.name : null);
    if (!environment.production) {
      if (environment.showObsDebug || environment.disablePolling) {
        const spy = create();
        if (environment.showObsDebug) {
          // spy.log('entity-obs');
          // spy.log('entity-request-obs');
          spy.log('list-pagination');
          spy.log('list-sort');
          spy.log('local-list');
          spy.log('pageSubObs');
          spy.log('actual-page-obs');
          spy.log('stat-obs');
          // spy.log('list');
        }
        if (environment.disablePolling) {
          spy.pause('poll');
        }
      }
    }
github jupyterlab / jupyterlab-data-explorer / packages / dataregistry / src / testutils.ts View on Github external
constructor(observable: Observable) {
    observable.pipe(tag('ToPromise')).subscribe(next => {
      const promise = this._promises.pop();
      if (promise === undefined) {
        this._values.push(next);
      } else {
        promise(next);
      }
    });
  }
}

rxjs-spy

A debugging library for RxJS

MIT
Latest version published 2 years ago

Package Health Score

47 / 100
Full package analysis