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

TypeScript operators.flatMap函数代码示例

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

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



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

示例1: filter

 .subscribe(doc => {
     if (!validationByDoc.has(doc.uri)) {
         const uri = doc.uri;
         if (isUriBlackListed(uri)) {
             validationByDoc.set(doc.uri, validationRequestStream.pipe(
                 filter(doc => uri === doc.uri),
                 take(1),
                 tap(doc => log('Ignoring:', doc.uri)),
                 ).subscribe()
             );
         } else {
             validationByDoc.set(doc.uri, validationRequestStream.pipe(
                 filter(doc => uri === doc.uri),
                 tap(doc => log('Request Validate:', doc.uri)),
                 debounceTime(50),
                 tap(doc => log('Request Validate 2:', doc.uri)),
                 flatMap(async doc => ({ doc, settings: await getActiveSettings(doc) }) as DocSettingPair),
                 debounce(dsp => timer(dsp.settings.spellCheckDelayMs || defaultDebounce)
                     .pipe(filter(() => !isValidationBusy))
                 ),
                 flatMap(validateTextDocument),
                 ).subscribe(diag => connection.sendDiagnostics(diag))
             );
         }
     }
 });
开发者ID:Jason-Rev,项目名称:vscode-spell-checker,代码行数:26,代码来源:server.ts


示例2: submit

 submit() {
   this.route.data.pipe(
     pluck('match', 'data', 'id'),
     flatMap((matchId: any) => this.update.update(matchId, this.form.value)),
     flatMap(result => this.updateRouteData(result))
   )
   .subscribe(() => this.router.navigate(['..'], { relativeTo: this.route }));
 }
开发者ID:mightymoose,项目名称:mmoaig,代码行数:8,代码来源:match-edit.component.ts


示例3: ngOnInit

 ngOnInit() {
   this.route.data.pipe(
     pluck('match', 'data', 'relationships', 'participants', 'data'),
     map((bots: any) => bots.map(bot => this.botSourcePath.botSourcePath(bot.id))),
     map(botPaths => botPaths.map(botPath => new Worker(botPath))),
     flatMap(() => this.createRound()),
     flatMap(() => this.checkForMatchCompletion()),
     filter(t => t)
   ).subscribe(() => this.router.navigate(['match-complete']));
 }
开发者ID:mightymoose,项目名称:mmoaig,代码行数:10,代码来源:rock-paper-scissors-match-runner.component.ts


示例4: getUrlById

 /**
  * Get url by id
  *
  * @param string id
  * @returns Observable<string>
  * @memberof ContentletService
  */
 getUrlById(id: string): Observable<string> {
     return this.getContentTypes().pipe(
         flatMap((structures: StructureTypeView[]) => structures),
         pluck('types'),
         flatMap((contentTypeViews: ContentTypeView[]) => contentTypeViews),
         filter(
             (contentTypeView: ContentTypeView) =>
                 contentTypeView.variable.toLocaleLowerCase() === id
         ),
         pluck('action')
     );
 }
开发者ID:dotCMS,项目名称:core-web,代码行数:19,代码来源:dot-content-type.service.ts


示例5: pollForChanges

  pollForChanges(seriesImport: SeriesImportModel): Observable<SeriesImportModel> {

    let lastReceived = null;

    let seriesImportPoller = interval(1000)
      .pipe(
        flatMap(() => {
          return seriesImport.doc.reload();
        }),
        map(doc => {
          let parentAccountDoc = seriesImport.parent;
          seriesImport.init(parentAccountDoc, doc, false);
          return new SeriesImportModel(parentAccountDoc, doc);
        }),
        takeWhile((si) => {
          // HACK
          // https://github.com/ReactiveX/rxjs/issues/2420
          // TODO fixed in rxjs 6
          if (lastReceived !== null) {
            return false;
          }
          if (si.isFinished()) {
            lastReceived = si;
          }
          return true;
        })
      );

    return concat(
      observableOf(seriesImport),
      seriesImportPoller
    );
  }
开发者ID:PRX,项目名称:publish.prx.org,代码行数:33,代码来源:series-import.service.ts


示例6: ngOnInit

 ngOnInit() {
     this.authService.GetAuthInfo()
         .pipe(
             tap((authInfo: TinderAuthInfo) => this.authInfo = authInfo),
             flatMap((authInfo: TinderAuthInfo) => this.tinderService.Authenticate(this.authInfo)))            
         .subscribe((authResp: any) => this.xAuthToken = authResp['token'])
 }
开发者ID:MikeCook9994,项目名称:TwitchPlaysTinder,代码行数:7,代码来源:app.component.ts


示例7: validateTextDocumentAsync

export function validateTextDocumentAsync(textDocument: TextDocument, options: CSpellUserSettings): Observable<Diagnostic> {
    const { diagnosticLevel = DiagnosticSeverity.Information.toString() } = options;
    const severity = diagSeverityMap.get(diagnosticLevel.toLowerCase()) || DiagnosticSeverity.Information;
    const limit = (options.checkLimit || defaultCheckLimit) * 1024;
    const text = textDocument.getText().slice(0, limit);
    return from(validateText(text, options)).pipe(
        flatMap(a => a),
        filter(a => !!a),
        map(a => a!),
        // Convert the offset into a position
        map(offsetWord => ({...offsetWord, position: textDocument.positionAt(offsetWord.offset) })),
        // Calculate the range
        map(word => ({
            ...word,
            range: {
                start: word.position,
                end: ({...word.position, character: word.position.character + word.text.length })
            }
        })),
        // Convert it to a Diagnostic
        map(({text, range}) => ({
            severity,
            range: range,
            message: `"${text}": Unknown word.`,
            source: diagSource
        })),
    );
}
开发者ID:Jason-Rev,项目名称:vscode-spell-checker,代码行数:28,代码来源:validator.ts


示例8: sendRequest

    private sendRequest(url: string, options: RequestOptionsArgs): Observable<string> {
        // make a copy
        let options1 = new RequestOptions();
        options1.method = options.method;
        options1 = options1.merge(options);
        let resource = this.adalService.GetResourceForEndpoint(url);
        let authenticatedCall: any;
        if (resource) {
            if (this.adalService.userInfo.isAuthenticated) {
                authenticatedCall = this.adalService.acquireToken(resource).pipe(flatMap((token: string) => {
                        if (options1.headers == null) {
                            options1.headers = new Headers();
                        }
                        options1.headers.set('Authorization', 'Bearer ' + token);
                        return this.http.request(url, options1).pipe(catchError(this.handleError));
                    }));
            }
            else {
                authenticatedCall = Observable.throw(new Error('User Not Authenticated.'));
            }
        }
        else {
            authenticatedCall = this.http.request(url, options).pipe(map(this.extractData), catchError(this.handleError));
        }

        return authenticatedCall;
    }
开发者ID:Jonah-Jordan,项目名称:angularx-adal,代码行数:27,代码来源:authHttp.service.ts


示例9: getAllContentTypes

 /**
  * Gets all content types excluding the RECENT ones
  *
  * @returns Observable<StructureTypeView[]>
  */
 getAllContentTypes(): Observable<StructureTypeView[]> {
     return this.getContentTypes()
         .pipe(
             flatMap((structures: StructureTypeView[]) => structures),
             filter((structure: StructureTypeView) => !this.isRecentContentType(structure))
         )
         .pipe(toArray());
 }
开发者ID:dotCMS,项目名称:core-web,代码行数:13,代码来源:dot-content-type.service.ts


示例10: ofType

const fetchIssuesEpic = (action$, store) =>
  action$.pipe(
    ofType(FETCH_ISSUES),
    flatMap(({ repoId, page }) => {
      if (List.isList(repoId)) {
        return fetchMapIssues(repoId as List<string>, store.value, page);
      }

      return fetchMapIssue(repoId as string, store.value, page);
    }),
    flatMap(issues => {
      const { formattedIssues, labels } = serializeIssuesLabels(issues);

      const actions = [add(formattedIssues), addLabels(labels), stopLoading()];

      return of(...actions);
    })
  );
开发者ID:alex3165,项目名称:github-issues,代码行数:18,代码来源:issues.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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