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

TypeScript rxjs.concat函数代码示例

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

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



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

示例1: ngAfterViewInit

    ngAfterViewInit() {

        const searchLessons$ =  fromEvent<any>(this.input.nativeElement, 'keyup')
            .pipe(
                map(event => event.target.value),
                debounceTime(400),
                distinctUntilChanged(),
                switchMap(search => this.loadLessons(search))
            );

        const initialLessons$ = this.loadLessons();

        this.lessons$ = concat(initialLessons$, searchLessons$);

    }
开发者ID:mrplanktonlex,项目名称:rxjs-course,代码行数:15,代码来源:course.component.ts


示例2: ngxsOnInit

  ngxsOnInit({ getState, dispatch }: StateContext<AppStateModel>) {
    this.router.events.pipe(
      filter(evt => evt instanceof ActivationEnd)
    ).subscribe((event: ActivationEnd) => {
      const state = {...getState()};
      const newSiteName = event.snapshot.queryParams['site'] || '';
      const newSectionName = !event.snapshot.queryParams['section'] ? null : event.snapshot.queryParams['section'];

      // Set current site and section
      if (state.site !== newSiteName || state.section !== newSectionName) {
        dispatch(new UpdateAppStateAction({site: newSiteName, section: newSectionName}));
      }
    });

    this.router.events.pipe(
      filter(event => event instanceof NavigationEnd),
      map((event: NavigationEnd) => event.url.split('?')[0]),
      filter(url => url !== '/' && url !== '/login')
    ).subscribe((url: string) => {
      dispatch(new UpdateAppStateAction({lastRoute: url}));
    });

    this.appStateService.getAppMetadata().pipe(take(1))
      .subscribe({
        next: (metadata) => {
          dispatch(new UpdateAppStateAction(metadata));
        },
        error: (error) => console.error(error)
      });

    concat(
      this.appStateService.getInitialState('').pipe(take(1)),
      // After each subsequent successful login, initialize the state
      this.actions$.pipe(
        ofActionSuccessful(UserLoginAction),
        switchMap(() => this.appStateService.getInitialState('').pipe(take(1)))
      )
    )
    .subscribe({
      next: (response) => {
        dispatch(new InitAppStateAction({urls: response.urls}));
      },
      error: (error) => console.error(error)
    });
  }
开发者ID:berta-cms,项目名称:berta,代码行数:45,代码来源:app.state.ts


示例3: SchematicsException

    (tree: Tree, context: SchematicContext): Observable<Tree> => {
      const packageJsonContent = tree.read('/package.json');
      if (!packageJsonContent) {
        throw new SchematicsException('Could not find package.json.');
      }
      const packageJson = JSON.parse(packageJsonContent.toString());
      const packages: { [name: string]: string } = {};
      for (const name of supportedPackages) {
        packages[name] = version;
      }

      return concat(
        _getRecursiveVersions(packageJson, packages, allVersions, context.logger, loose).pipe(
          ignoreElements(),
        ),
        observableOf(tree),
      );
    },
开发者ID:iwe7,项目名称:devkit,代码行数:18,代码来源:npm.ts


示例4: it

  it('should use the scheduler even when one Observable is concat\'d', (done) => {
    let e1Subscribed = false;
    const e1 = defer(() => {
      e1Subscribed = true;
      return of('a');
    });

    concat(e1, asyncScheduler)
      .subscribe({
        error: done,
        complete: () => {
          expect(e1Subscribed).to.be.true;
          done();
        }
      });

    expect(e1Subscribed).to.be.false;
  });
开发者ID:DallanQ,项目名称:rxjs,代码行数:18,代码来源:concat-spec.ts


示例5: it

  it('should accept closing selector that returns a resolved promise', (done: MochaDone) => {
    const e1 = concat(of(1),
      timer(10).pipe(mapTo(2)),
      timer(10).pipe(mapTo(3)),
      timer(100).pipe(mapTo(4))
    );
    const expected = [[1]];

    e1.pipe(bufferToggle(of(10), () => new Promise((resolve: any) => { resolve(42); })))
      .subscribe((x) => {
        expect(x).to.deep.equal(expected.shift());
      }, () => {
        done(new Error('should not be called'));
      }, () => {
        expect(expected.length).to.be.equal(0);
        done();
      });
  });
开发者ID:tomastrajan,项目名称:rxjs,代码行数:18,代码来源:bufferToggle-spec.ts


示例6: it

  it('supports custom rules in the project (fail)', done => {
    // This test is disabled on Windows Bazel runs because it relies on TSLint custom rule
    // loading behavior, which doesn't work with runfile resolution.
    if (isWindowsBazel) {
      done();

      return;
    }

    const testRunner = new SchematicTestRunner(
      '@_/test',
      path.join(__dirname, 'test/collection.json'),
    );

    const host = new TempScopedNodeJsSyncHost();
    host.write(normalize('/file.ts'), virtualFs.stringToFileBuffer(`
      console.log('hello world');
    `)).subscribe();
    const tree = new UnitTestTree(new HostTree(host));

    const messages: string[] = [];
    let error = false;

    concat(
      testRunner.runSchematicAsync('custom-rule', { shouldPass: false }, tree),
      new Observable<void>(obs => {
        process.chdir(getSystemPath(host.root));
        testRunner.logger.subscribe(x => messages.push(x.message));
        testRunner.engine.executePostTasks().subscribe(obs);
      }).pipe(
        catchError(() => {
          error = true;

          return [];
        }),
      ),
      new Observable<void>(obs => {
        expect(messages.find(msg => /\bcustom-rule fail\b/.test(msg))).not.toBeUndefined();
        expect(error).toBe(true);

        obs.complete();
      }),
    ).toPromise().then(done, done.fail);
  });
开发者ID:DevIntent,项目名称:angular-cli,代码行数:44,代码来源:executor_spec.ts


示例7: concatMap

    concatMap(fullUrl => {
      let maybeRequest = npmPackageJsonCache.get(fullUrl);
      if (maybeRequest) {
        return maybeRequest;
      }

      return concat(
        getNpmConfigOption('proxy'),
        getNpmConfigOption('https-proxy'),
      ).pipe(
        toArray(),
        concatMap(options => {
          const subject = new ReplaySubject<NpmRepositoryPackageJson>(1);

          const client = new RegistryClient({
            proxy: {
              http: options[0],
              https: options[1],
            },
          });
          client.log.level = 'silent';
          const params = {
            timeout: 30000,
          };

          client.get(
            fullUrl,
            params,
            (error: object, data: NpmRepositoryPackageJson) => {
            if (error) {
              subject.error(error);
            }

            subject.next(data);
            subject.complete();
          });

          maybeRequest = subject.asObservable();
          npmPackageJsonCache.set(fullUrl.toString(), maybeRequest);

          return maybeRequest;
        }),
      );
    }),
开发者ID:iwe7,项目名称:devkit,代码行数:44,代码来源:npm.ts


示例8: ngxsOnInit

  ngxsOnInit({ dispatch }: StateContext<ShopSettingsModel>) {
    return concat(
      this.stateService.getInitialState('', 'settings').pipe(take(1)),
      /* LOGIN: */
      this.store$.select(UserState.isLoggedIn).pipe(
        pairwise(),
        filter(([wasLoggedIn, isLoggedIn]) => !wasLoggedIn && isLoggedIn),
        switchMap(() => this.stateService.getInitialState('', 'settings').pipe(take(1)))
      )
    ).subscribe((settings) => {
      const newState: {[k: string]: any} = {};

      for (const siteSlug in settings) {
        newState[siteSlug] = this.initializeShopSettingsForSite(settings[siteSlug]);
      }

      dispatch(new InitShopSettingsAction(newState));
    });
  }
开发者ID:berta-cms,项目名称:berta,代码行数:19,代码来源:shop-settings.state.ts


示例9: it

  it('should auditTime events multiple times', () => {
    const expected = ['1-2', '2-2'];
    concat(
      timer(0, 10, rxTestScheduler).pipe(
        take(3),
        map((x: number) => '1-' + x)
      ),
      timer(80, 10, rxTestScheduler).pipe(
        take(5),
        map((x: number) => '2-' + x)
      )
    ).pipe(
      auditTime(50, rxTestScheduler)
    ).subscribe((x: string) => {
        expect(x).to.equal(expected.shift());
      });

    rxTestScheduler.flush();
  });
开发者ID:DallanQ,项目名称:rxjs,代码行数:19,代码来源:auditTime-spec.ts


示例10: EncryptedMediaError

      .pipe(mergeMap((keyStatusesEvent: Event) => {
        log.debug("EME: keystatuseschange event", session, keyStatusesEvent);

        // find out possible errors associated with this event
        const warnings : IEMEWarningEvent[] = [];
        (session.keyStatuses as any).forEach((keyStatus : string, keyId : string) => {
          // Hack present because the order of the arguments has changed in spec
          // and is not the same between some versions of Edge and Chrome.
          if (keyStatus === KEY_STATUS_EXPIRED || keyId === KEY_STATUS_EXPIRED) {
            const { throwOnLicenseExpiration } = keySystem;
            const error = new EncryptedMediaError("KEY_STATUS_CHANGE_ERROR",
              "A decryption key expired", false);

            if (throwOnLicenseExpiration !== false) {
              throw error;
            }
            warnings.push({ type: "warning", value: error });
          }

          if (KEY_STATUS_ERRORS[keyId]) {
            throw new EncryptedMediaError("KEY_STATUS_CHANGE_ERROR",
              "An invalid key status has been encountered: " + keyId, true);
          } else if (KEY_STATUS_ERRORS[keyStatus]) {
            throw new EncryptedMediaError("KEY_STATUS_CHANGE_ERROR",
              "An invalid key status has been encountered: " + keyStatus, true);
          }
        });

        const warnings$ = warnings.length ? observableOf(...warnings) : EMPTY;
        const handledKeyStatusesChange$ = tryCatch(() => {
          return keySystem && keySystem.onKeyStatusesChange ?
            castToObservable(
              keySystem.onKeyStatusesChange(keyStatusesEvent, session)
            ) as Observable<TypedArray|ArrayBuffer|null> : EMPTY;
        }, undefined).pipe() // TS or RxJS Bug?
          .pipe(
            catchError((error: Error) => {
              throw new EncryptedMediaError(
                "KEY_STATUS_CHANGE_ERROR", error.toString(), true);
            }),
            map((licenseObject) => ({
              type: "key-status-change" as "key-status-change",
              value : { license: licenseObject },
            }))
          );
        return observableConcat(warnings$, handledKeyStatusesChange$);
      }));
开发者ID:canalplus,项目名称:rx-player,代码行数:47,代码来源:handle_session_events.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript rxjs.defer函数代码示例发布时间:2022-05-25
下一篇:
TypeScript rxjs.combineLatest函数代码示例发布时间: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