當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。