当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript operators.flatMap函数代码示例

本文整理汇总了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;未经允许,请勿转载。