本文整理匯總了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[]>;
}