Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
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")
);
}
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')
);
}
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(),
);
}
.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(),
);
}
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')
);
}
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');
}
}
}
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');
}
}
}
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');
}
}
}
constructor(observable: Observable) {
observable.pipe(tag('ToPromise')).subscribe(next => {
const promise = this._promises.pop();
if (promise === undefined) {
this._values.push(next);
} else {
promise(next);
}
});
}
}