• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript operators.delay函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中rxjs/operators.delay函数的典型用法代码示例。如果您正苦于以下问题:TypeScript delay函数的具体用法?TypeScript delay怎么用?TypeScript delay使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了delay函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: ngOnInit

	// I get called once when the component is being mounted.
	public ngOnInit() : void {

		this.parentParamMapSubscription = this.activatedRoute.parent.paramMap
			// TIMING HACK: We need to add a tick-delay between the root ParamMap emit
			// and the callback in order to fix several Angular bugs.
			.pipe( delay( 10 ) )
			.subscribe(
				( paramMap: ParamMap ) : void => {

					this.loadData( +paramMap.get( "id" ) );

				}
			)
		;

		this.paramMapSubscription = this.activatedRoute.paramMap
			// TIMING HACK: We need to add a tick-delay between the root ParamMap emit
			// and the callback in order to fix several Angular bugs.
			.pipe( delay( 10 ) )
			.subscribe(
			( paramMap: ParamMap ) : void => {

					this.filterText = ( paramMap.get( "filterText" ) || "" );
					this.filterType = ( paramMap.get( "filterType" ) || "active" );
					this.applyFilterToList();

				}
			)
		;

	}
开发者ID:bennadel,项目名称:JavaScript-Demos,代码行数:32,代码来源:screens-view.component.ts


示例2: of

 .and.callFake(function (params: RequestQueryParams) {
   if (params && params.get('username')) {
     return of(mockData2).pipe(delay(0));
   } else {
     if (params.get('page') === '1') {
       mockData.data = mockItems.slice(0, 15);
     } else {
       mockData.data = mockItems.slice(15, 18);
     }
     return of(mockData).pipe(delay(0));
   }
 });
开发者ID:reasonerjt,项目名称:harbor,代码行数:12,代码来源:recent-log.component.spec.ts


示例3: race2

 race2() {
   // Throws an error and ignores the other observables.
   const first = of('first').pipe(
     delay(100),
     map(_ => {
       throw 'error';
     })
   );
   const second = of('second').pipe(delay(200));
   const third = of('third').pipe(delay(300));
   //  nothing logged
   race(first, second, third).subscribe(val => console.log(val));
 }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:13,代码来源:conditional.service.ts


示例4: zip1

 zip1() {
   const sourceOne = of('Hello');
   const sourceTwo = of('World!');
   const sourceThree = of('Goodbye');
   const sourceFour = of('World!');
   // wait until all observables have emitted a value then emit all as an array
   const example = zip(
     sourceOne,
     sourceTwo.pipe(delay(1000)),
     sourceThree.pipe(delay(2000)),
     sourceFour.pipe(delay(3000))
   );
   // output: ["Hello", "World!", "Goodbye", "World!"]
   const subscribe = example.subscribe(val => console.log(val));
 }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:15,代码来源:combining.service.ts


示例5: getPeople

 getPeople(term: string = null): Observable<Person[]> {
     let items = getMockPeople();
     if (term) {
         items = items.filter(x => x.name.toLocaleLowerCase().indexOf(term.toLocaleLowerCase()) > -1);
     }
     return of(items).pipe(delay(500));
 }
开发者ID:fawzaar,项目名称:ng-select,代码行数:7,代码来源:data.service.ts


示例6: exhaustMap1

  exhaustMap1() {
    const sourceInterval = interval(1000);
    const delayedInterval = sourceInterval.pipe(delay(10), take(4));

    const exhaustSub = merge(
      //  delay 10ms, then start interval emitting 4 values
      delayedInterval,
      //  emit immediately
      of(true)
    )
      .pipe(exhaustMap(_ => sourceInterval.pipe(take(5))))
      /*
       *  The first emitted value (of(true)) will be mapped
       *  to an interval observable emitting 1 value every
       *  second, completing after 5.
       *  Because the emissions from the delayed interval
       *  fall while this observable is still active they will be ignored.
       *
       *  Contrast this with concatMap which would queue,
       *  switchMap which would switch to a new inner observable each emission,
       *  and mergeMap which would maintain a new subscription for each emitted value.
       */
      //  output: 0, 1, 2, 3, 4
      .subscribe(val => console.log(val));
  }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:25,代码来源:transforming.service.ts


示例7: unsubscribe

export function fromRef<T>(ref: DatabaseQuery, event: ListenEvent, listenType = 'on'): Observable<AngularFireAction<DatabaseSnapshot<T>>> {
  return new Observable<SnapshotPrevKey<T>>(subscriber => {
    const fn = ref[listenType](event, (snapshot, prevKey) => {
      subscriber.next({ snapshot, prevKey });
      if (listenType == 'once') { subscriber.complete(); }
    }, subscriber.error.bind(subscriber));
    if (listenType == 'on') {
      return { unsubscribe() { ref.off(event, fn)} };
    } else {
      return { unsubscribe() { } };
    }
  }).pipe(
    map(payload =>  {
      const { snapshot, prevKey } = payload;
      let key: string | null = null;
      if (snapshot.exists()) { key = snapshot.key; }
      return { type: event, payload: snapshot, prevKey, key };
    }),
    // Ensures subscribe on observable is async. This handles
    // a quirk in the SDK where on/once callbacks can happen
    // synchronously.
    delay(0),
    share()
  );
}
开发者ID:Tetsumote,项目名称:angularfire2,代码行数:25,代码来源:fromRef.ts


示例8: getAll

 getAll(): Observable<Article[]> {
   return this.apiService.get('articles')
     .pipe(
       delay(1000),
       map(data => data)
     );
 }
开发者ID:ricardorojass,项目名称:blog,代码行数:7,代码来源:article.service.ts


示例9: mergeMap

            mergeMap(({ payload: { notification } }: ITriggerNotificationAction) => {
                if (notification.ttl === undefined) return EMPTY

                return of(closeNotification(notification.id)).pipe(
                    delay(notification.ttl)
                )
            })
开发者ID:manishshanker,项目名称:wiremock-ui,代码行数:7,代码来源:epics.ts


示例10: ofType

const errorHandlingEpics = action$ =>
  action$.pipe(
    ofType(ERROR),
    delay(3000),
    take(1),
    map(stopError)
  );
开发者ID:alex3165,项目名称:github-issues,代码行数:7,代码来源:config.ts


示例11: resolve

  resolve(route: ActivatedRouteSnapshot): Observable<User | null> {
    console.log('UserResolve Guard is called');

    if (!route.paramMap.has('userID')) {
      return of(new User(null, '', ''));
    }

    this.spinner.show();
    const id = +route.paramMap.get('userID');

    return this.userArrayService.getUser(id).pipe(
      delay(2000),
      map(user => {
        if (user) {
          return user;
        } else {
          this.router.navigate(['/users']);
          return of(null);
        }
      }),
      tap(() => this.spinner.hide()),
      catchError(() => {
        this.spinner.hide();
        this.router.navigate(['/users']);
        return of(null);
      })
    );
  }
开发者ID:ivanina-ilya,项目名称:An2-4-Routing,代码行数:28,代码来源:user-resolve.guard.ts


示例12: getWatchHandlers

function getWatchHandlers(
  buildOutput$: Rx.Observable<string>,
  {
    handlerDelay = defaultHandlerDelay,
    handlerReadinessTimeout = defaultHandlerReadinessTimeout,
  }: IWatchOptions
) {
  const typescriptHandler = buildOutput$.pipe(
    first(data => data.includes('$ tsc')),
    map(() =>
      buildOutput$.pipe(first(data => data.includes('Compilation complete.')), mapTo('tsc'))
    )
  );

  const webpackHandler = buildOutput$.pipe(
    first(data => data.includes('$ webpack')),
    map(() => buildOutput$.pipe(first(data => data.includes('Chunk Names')), mapTo('webpack')))
  );

  const defaultHandler = Rx.of(undefined).pipe(
    delay(handlerReadinessTimeout),
    map(() => buildOutput$.pipe(timeout(handlerDelay), catchError(() => Rx.of('timeout'))))
  );

  return [typescriptHandler, webpackHandler, defaultHandler];
}
开发者ID:Jaaess,项目名称:kibana,代码行数:26,代码来源:watch.ts


示例13: forkJoin1

  forkJoin1() {
    const myPromise = val =>
      new Promise(resolve =>
        setTimeout(() => resolve(`Promise Resolved: ${val}`), 5000)
      );

    /*
      when all observables complete, give the last
      emitted value from each as an array
    */
    const example = forkJoin(
      // emit 'Hello' immediately
      of('Hello'),
      // emit 'World' after 1 second
      of('World').pipe(delay(1000)),
      // emit 0 after 1 second
      interval(1000).pipe(take(1)),
      // emit 0...1 in 1 second interval
      interval(1000).pipe(take(2)),
      // promise that resolves to 'Promise Resolved' after 5 seconds
      myPromise('RESULT')
    );
    // output: ["Hello", "World", 0, 1, "Promise Resolved: RESULT"]
    const subscribe = example.subscribe(val => console.log(val));
  }
开发者ID:zwvista,项目名称:SampleMisc,代码行数:25,代码来源:combining.service.ts


示例14: beforeEach

  beforeEach(() => {
    fixture = TestBed.createComponent(RepositoryComponent);

    compRepo = fixture.componentInstance;

    compRepo.projectId = 1;
    compRepo.hasProjectAdminRole = true;
    compRepo.repoName = 'library/nginx';
    repositoryService = fixture.debugElement.injector.get(RepositoryService);
    systemInfoService = fixture.debugElement.injector.get(SystemInfoService);
    tagService = fixture.debugElement.injector.get(TagService);
    userPermissionService = fixture.debugElement.injector.get(UserPermissionService);
    labelService = fixture.debugElement.injector.get(LabelService);

    spyRepos = spyOn(repositoryService, 'getRepositories').and.returnValues(of(mockRepo).pipe(delay(0)));
    spySystemInfo = spyOn(systemInfoService, 'getSystemInfo').and.returnValues(of(mockSystemInfo).pipe(delay(0)));
    spyTags = spyOn(tagService, 'getTags').and.returnValues(of(mockTagData).pipe(delay(0)));

    spyLabels = spyOn(labelService, 'getGLabels').and.returnValues(of(mockLabels).pipe(delay(0)));
    spyLabels1 = spyOn(labelService, 'getPLabels').and.returnValues(of(mockLabels1).pipe(delay(0)));
    spyOn(userPermissionService, "getPermission")
    .withArgs(compRepo.projectId, USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.KEY, USERSTATICPERMISSION.REPOSITORY_TAG_LABEL.VALUE.CREATE )
    .and.returnValue(of(mockHasAddLabelImagePermission))
     .withArgs(compRepo.projectId, USERSTATICPERMISSION.REPOSITORY.KEY, USERSTATICPERMISSION.REPOSITORY.VALUE.PULL )
     .and.returnValue(of(mockHasRetagImagePermission))
     .withArgs(compRepo.projectId, USERSTATICPERMISSION.REPOSITORY_TAG.KEY, USERSTATICPERMISSION.REPOSITORY_TAG.VALUE.DELETE )
     .and.returnValue(of(mockHasDeleteImagePermission))
     .withArgs(compRepo.projectId, USERSTATICPERMISSION.REPOSITORY_TAG_SCAN_JOB.KEY
      , USERSTATICPERMISSION.REPOSITORY_TAG_SCAN_JOB.VALUE.CREATE)
     .and.returnValue(of(mockHasScanImagePermission));
    fixture.detectChanges();
  });
开发者ID:reasonerjt,项目名称:harbor,代码行数:32,代码来源:repository.component.spec.ts


示例15: get

  get(id: string): Observable<Card> {
    const idMap: { [key: string]: IntroCard } = {
      'da39a3ee5e6b4b0d3255bfef95601890afd80709': {
        id: 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
        type: 'intro',
        langItemId: '1',
        next: '3da541559918a808c2402bba5012f6c60b27661c'
      },
      '3da541559918a808c2402bba5012f6c60b27661c': {
        id: '3da541559918a808c2402bba5012f6c60b27661c',
        type: 'intro',
        langItemId: '2',
        previous: 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
        next: '4b430c99a32d2c7572c6382c4a7700dea297335a',
      },
      '4b430c99a32d2c7572c6382c4a7700dea297335a': {
        id: '4b430c99a32d2c7572c6382c4a7700dea297335a',
        type: 'intro',
        langItemId: '3',
        previous: '3da541559918a808c2402bba5012f6c60b27661c'
      }
    }

    return of(idMap[id]).pipe(delay(0))
  }
开发者ID:jamesbs,项目名称:flashcards,代码行数:25,代码来源:card.provider.ts


示例16: it

  it('refreshToken succeed', (done) => {
      const strategySpy = spyOn(dummyAuthStrategy, 'refreshToken')
        .and
        .returnValue(observableOf(successRefreshTokenResult)
          .pipe(
            delay(1000),
          ));

      const tokenServiceSetSpy = spyOn(tokenService, 'set')
        .and
        .returnValue(observableOf(null));

      authService.refreshToken(ownerStrategyName).subscribe((authRes: NbAuthResult) => {
        expect(strategySpy).toHaveBeenCalled();
        expect(tokenServiceSetSpy).toHaveBeenCalled();

        expect(authRes.isFailure()).toBeFalsy();
        expect(authRes.isSuccess()).toBeTruthy();
        expect(authRes.getMessages()).toEqual(['Successfully refreshed token.']);
        expect(authRes.getErrors()).toEqual([]);
        expect(authRes.getRedirect()).toBeNull();
        expect(authRes.getToken()).toEqual(testToken);
        expect(authRes.getResponse()).toEqual(resp200);
        done();
      })
    },
开发者ID:Sistets,项目名称:AppDoctors,代码行数:26,代码来源:auth.spec.ts


示例17: ngOnInit

	public ngOnInit() : void {

		this.paramMapSubscription = this.activatedRoute.paramMap
			// TIMING HACK: We need to add a tick-delay between the root ParamMap emit
			// and the callback in order to fix several Angular bugs.
			.pipe( delay( 10 ) )
			.subscribe(
				( paramMap : ParamMap ) : void => {

					this.setType( paramMap.get( "type" ) );
					
				}
			)
		;

		this.unlisten = this.keyboardShortcuts.listen(
			{
				"Escape": ( event: KeyboardEvent ) : void => {

					this.closeModal();

				}
			},
			{
				priority: this.keyboardShortcuts.getPriority( "modal" ),
				// Enable the inputs option so that an input focused somewhere in the 
				// background won't prevent the Esc-key from closing the modal.
				inputs: true
			}
		);

	}
开发者ID:bennadel,项目名称:JavaScript-Demos,代码行数:32,代码来源:error-view.component.ts


示例18: list

 list() {
   return this.http.get<T[]>(this.API_URL)
     .pipe(
       delay(2000),
       tap(console.log)
     );
 }
开发者ID:loiane,项目名称:curso-angular2,代码行数:7,代码来源:crud-service.ts


示例19: it

    it('should allow null scope to bypass isolation', function(done) {
      const proxyRequest$ = new Subject<any>();
      function main(_sources: {HTTP: HTTPSource}) {
        return {
          HTTP: proxyRequest$,
        };
      }

      const {sources, run} = setup(main, {HTTP: makeHTTPDriver()});

      const ignoredRequest$ = of(uri + '/json');
      const request$ = of(uri + '/hello').pipe(delay(100));
      const scopedRequest$ = sources.HTTP.isolateSink(proxyRequest$, null);
      const scopedHTTPSource = sources.HTTP.isolateSource(sources.HTTP, null);

      const expected = [uri + '/json', uri + '/hello'];

      scopedHTTPSource.select().subscribe(function(response$: any) {
        assert.strictEqual(typeof response$.request, 'object');
        assert.strictEqual(response$.request.url, expected.shift());
        if (expected.length === 0) {
          done();
        }
      });

      run();

      merge(ignoredRequest$, request$).subscribe(proxyRequest$);
    });
开发者ID:,项目名称:,代码行数:29,代码来源:


示例20: getSomeCountries

 public getSomeCountries(countriesCount: number = 5, delayTime: number = 0): Observable<any[]> {
     return this.getResponse().pipe(
         delay(delayTime),
         map((response: AirportsResponse) => response.countries),
         map((countryNames: string[]) => countryNames.slice(0, countriesCount).map(countryName => ({ name: countryName })))
     );
 }
开发者ID:fshchudlo,项目名称:right-angled,代码行数:7,代码来源:airports.service.ts



注:本文中的rxjs/operators.delay函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript operators.delayWhen函数代码示例发布时间:2022-05-25
下一篇:
TypeScript operators.defaultIfEmpty函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap