本文整理汇总了TypeScript中rxjs/operators.throttleTime函数的典型用法代码示例。如果您正苦于以下问题:TypeScript throttleTime函数的具体用法?TypeScript throttleTime怎么用?TypeScript throttleTime使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了throttleTime函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fromEvent
() => {
var stream = fromEvent( document, "mousemove" ).pipe(
// While the mouse-events are being triggered continuously on the
// document (while the user is mousing-around), we only want to let
// one event through every few seconds.
throttleTime( 2000 ),
map(
( event: MouseEvent ) : MousePosition => {
return({
viewport: {
x: event.clientX,
y: event.clientY
},
document: {
x: event.pageX,
y: event.pageY
}
});
}
)
);
return( stream );
}
示例2: it
it('should throttle values until source raises error', () => {
const e1 = hot('-a--(bc)-------d---------------#');
const subs = '^ !';
const expected = '-a-------------d---------------#';
expectObservable(e1.pipe(throttleTime(50, rxTestScheduler))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(subs);
});
示例3: throttleTime
export const limitMessageRateEpic: Epic<ActionOf<any>, ActionOf<any>, StoreState, EpicDependencies> = action$ => {
return action$.ofType(limitMessageRatePayloadAction.type).pipe(
throttleTime(1),
map((action: ActionOf<LimitMessageRatePayload>) => {
const { exploreId, data, dataReceivedActionCreator } = action.payload;
return dataReceivedActionCreator({ exploreId, data });
})
);
};
示例4: getContacts
getContacts() {
return this.contactsApiClient.getContacts().valueChanges().pipe(map((users: User[]) => {
return users.filter((user: User) => {
return user.uid !== this.authService.getUid();
});
}))
.pipe(throttleTime(5000)) as Observable<User[]>;
}