本文整理匯總了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))
);
}
}
});
示例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 }));
}
示例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']));
}
示例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')
);
}
示例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
);
}
示例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'])
}
示例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
})),
);
}
示例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;
}
示例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());
}
示例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);
})
);