本文整理匯總了TypeScript中rxjs/operators.skipWhile函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript skipWhile函數的具體用法?TypeScript skipWhile怎麽用?TypeScript skipWhile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了skipWhile函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should handle predicate that throws', () => {
const source = hot('--a--b-^-c--d--e--f--g--h--|');
const sourceSubs = '^ !';
const expected = '--------#';
const predicate = function (v: string) {
if (v === 'e') {
throw new Error('nom d\'une pipe !');
}
return v !== 'f';
};
expectObservable(source.pipe(skipWhile(predicate))).toBe(expected, undefined, new Error('nom d\'une pipe !'));
expectSubscriptions(source.subscriptions).toBe(sourceSubs);
});
示例2: withLatestFrom
function waitForLoaded<T>(query: DatabaseQuery, action$: Observable<SnapshotAction<T>[]>) {
const loaded$ = loadedData<T>(query);
return loaded$
.pipe(
withLatestFrom(action$),
// Get the latest values from the "loaded" and "child" datasets
// We can use both datasets to form an array of the latest values.
map(([loaded, actions]) => {
// Store the last key in the data set
let lastKeyToLoad = loaded.lastKeyToLoad;
// Store all child keys loaded at this point
const loadedKeys = actions.map(snap => snap.key);
return { actions, lastKeyToLoad, loadedKeys }
}),
// This is the magical part, only emit when the last load key
// in the dataset has been loaded by a child event. At this point
// we can assume the dataset is "whole".
skipWhile(meta => meta.loadedKeys.indexOf(meta.lastKeyToLoad) === -1),
// Pluck off the meta data because the user only cares
// to iterate through the snapshots
map(meta => meta.actions)
);
}
示例3: higherOrder
export function skipWhile<T>(this: Observable<T>, predicate: (value: T, index: number) => boolean): Observable<T> {
return higherOrder(predicate)(this);
}
示例4: it
it('should support a predicate with an index', () => {
const o = of('foo', 'bar', 'baz').pipe(skipWhile((value, index) => index < 3)); // $ExpectType Observable<string>
});