当前位置: 首页>>代码示例>>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;未经允许,请勿转载。