本文整理汇总了TypeScript中rxjs/operators.skip函数的典型用法代码示例。如果您正苦于以下问题:TypeScript skip函数的具体用法?TypeScript skip怎么用?TypeScript skip使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了skip函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should emit rangeChange when selected start and end dates', (done) => {
rangepicker.visibleDate = new Date(2018, 8, 17);
showRangepicker();
rangepicker.rangeChange
.pipe(skip(1))
.subscribe((range: NbCalendarRange<Date>) => {
expect(range.start.getFullYear()).toEqual(2018);
expect(range.end.getFullYear()).toEqual(2018);
expect(range.start.getMonth()).toEqual(8);
expect(range.end.getMonth()).toEqual(8);
expect(range.start.getDate()).toEqual(1);
expect(range.end.getDate()).toEqual(3);
done();
});
// click on Sep 1
const startCell = overlay.querySelectorAll('.day-cell')[6];
(startCell as HTMLElement).click();
// click on Sep 3
const endCell = overlay.querySelectorAll('.day-cell')[8];
(endCell as HTMLElement).click();
fixture.detectChanges();
}, 5000);
示例2: it
it('should be able to filter snapshotChanges() types - added/modified', async (done) => {
const ITEMS = 10;
let { randomCollectionName, ref, stocks, names } = await collectionHarness(afs, ITEMS);
const nextId = ref.doc('a').id;
let count = 0;
const sub = stocks.snapshotChanges(['added', 'modified']).pipe(skip(1),take(2)).subscribe(data => {
count += 1;
if (count == 1) {
const change = data.filter(x => x.payload.doc.id === nextId)[0];
expect(data.length).toEqual(ITEMS + 1);
expect(change.payload.doc.data().price).toEqual(2);
expect(change.type).toEqual('added');
delayUpdate(stocks, names[0], { price: 2 });
}
if (count == 2) {
const change = data.filter(x => x.payload.doc.id === names[0])[0];
expect(data.length).toEqual(ITEMS + 1);
expect(change.payload.doc.data().price).toEqual(2);
expect(change.type).toEqual('modified');
}
}).add(() => {
deleteThemAll(names, ref).then(done).catch(done.fail);
});
names = names.concat([nextId]);
delayAdd(stocks, nextId, { price: 2 });
});
示例3: it
it('should allow going forward a route with type `goForward`', done => {
function main(_sources: {history: Observable<Location>}) {
return {
history: of<HistoryInput | string>(
'/test',
'/other',
{type: 'go', amount: -1},
{type: 'goForward'}
),
};
}
const {sources, run} = setup(main, {
history: makeServerHistoryDriver(),
});
const expected = ['/test', '/other', '/test', '/other'];
sources.history.pipe(skip(1)).subscribe({
next(location: Location) {
assert.strictEqual(location.pathname, expected.shift());
if (expected.length === 0) {
done();
}
},
error: done,
complete: () => {
done('complete should not be called');
},
});
run();
});
示例4: it
it('should get Gamma sidekick after creating and assigning one', (done: DoneFn) => {
// Skip(1), the initial state in which Gamma has no sidekick
// Note that BOTH dispatches complete synchronously, before the selector updates
// so we only have to skip one.
createHeroSidekickSelector$(3)
.pipe(skip(1))
.subscribe(sk => {
expect(sk.name).toBe('Robin');
done();
});
// create a new sidekick
let action: EntityAction = eaFactory.create<Sidekick>('Sidekick', EntityOp.ADD_ONE, {
id: 42,
name: 'Robin'
});
store.dispatch(action);
// assign new sidekick to Gamma
action = eaFactory.create<Update<Hero>>('Hero', EntityOp.UPDATE_ONE, {
id: 3,
changes: { id: 3, sidekickFk: 42 }
});
store.dispatch(action);
});
示例5: resolve
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Page<Item>> {
this.store.dispatch(
new FindItemsByPodcastsAndPageAction(route.params.id)
);
return this.store.pipe(select(selectPodcastItems), skip(1), take(1));
}
示例6: it
it('should unsubscribe scheduled actions after execution', () => {
let subscribeSpy: any = null;
const counts: number[] = [];
const e1 = cold('a|');
const expected = '--a-(a|)';
const duration = time('-|');
const result = e1.pipe(
repeatWhen(notifications => {
const delayed = notifications.pipe(delay(duration, rxTestScheduler));
subscribeSpy = sinon.spy(delayed['source'], 'subscribe');
return delayed;
}),
skip(1),
take(2),
tap({
next() {
const [[subscriber]] = subscribeSpy.args;
counts.push(subscriber._subscriptions.length);
},
complete() {
expect(counts).to.deep.equal([1, 1]);
}
})
);
expectObservable(result).toBe(expected);
});
示例7: it
it('should emit true when the socket establishes a connection with the ws server', done => {
const brayns = new Client(host);
brayns.ready.pipe(skip(1), take(1))
.subscribe(ready => {
expect(ready).toBe(true);
done();
});
});
示例8: it
it('should complete regardless of skip count if source is empty', () => {
const e1 = cold('|');
const e1subs = '(^!)';
const expected = '|';
expectObservable(e1.pipe(skip(3))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
});
示例9: asDiagram
asDiagram('skip(3)')('should skip values before a total', () => {
const source = hot('--a--b--c--d--e--|');
const subs = '^ !';
const expected = '-----------d--e--|';
expectObservable(source.pipe(skip(3))).toBe(expected);
expectSubscriptions(source.subscriptions).toBe(subs);
});