本文整理汇总了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>
});