當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript operators.throttleTime函數代碼示例

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

			}
開發者ID:bennadel,項目名稱:JavaScript-Demos,代碼行數:28,代碼來源:app.component.ts

示例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);
  });
開發者ID:DallanQ,項目名稱:rxjs,代碼行數:8,代碼來源:throttleTime-spec.ts

示例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 });
    })
  );
};
開發者ID:grafana,項目名稱:grafana,代碼行數:9,代碼來源:epics.ts

示例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[]>;
  }
開發者ID:Howsky,項目名稱:chatapp,代碼行數:9,代碼來源:contacts.service.ts


注:本文中的rxjs/operators.throttleTime函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。