本文整理匯總了TypeScript中rxjs.Observable.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Observable.default方法的具體用法?TypeScript Observable.default怎麽用?TypeScript Observable.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rxjs.Observable
的用法示例。
在下文中一共展示了Observable.default方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: buildURL
({ owner, repoName, mergeRequestID, diffID }: GetBaseCommitIDInput) => {
const mrURL = buildURL(owner, repoName, `/merge_requests/${mergeRequestID}`)
// If we have a `diffID`, retrieve the information for that individual diff.
if (diffID) {
return get<DiffVersionsResponse>(`${mrURL}/versions/${diffID}`).pipe(
map(({ base_commit_sha }) => base_commit_sha)
)
}
// Otherwise, just get the overall base `commitID` for the merge request.
return get<MergeRequestResponse>(mrURL).pipe(map(({ diff_refs: { base_sha } }) => base_sha))
},
示例2: user
export const bid = (af: AngularFire) => (jobId: string): Observable<Bid> =>
user(af)
.filter(id)
.flatMap(u => af.database.object(`bids/${jobId}/${u.$key}`, { preserveSnapshot: true }))
.skipWhile(s => s.val() == null)
.map(s => assign(s.val(), {$key: s.key}))
.onErrorResumeNext(null);
示例3: getStartCommand
export const installShellCommand = () => {
const directories = getStartCommand();
if (!directories) {
dialog.showErrorBox(
"nteract application not found.",
"Could not locate nteract executable."
);
return;
}
const [exe, rootDir, binDir] = directories;
const obs = installShellCommandsObservable(exe, rootDir, binDir);
obs.subscribe(
() => {},
err => dialog.showErrorBox("Could not write shell script.", err.message),
() =>
dialog.showMessageBox({
title: "Command installed.",
message: 'The shell command "nteract" is installed.',
detail: 'Get help with "nteract --help".',
buttons: ["OK"]
})
);
};
示例4: user
export const jobs$ = (af: AngularFire): Observable<Job[]> =>
user(af)
.filter(id)
.flatMap(u => af.database.object(`owner_to_jobs/${u.$key}`, { preserveSnapshot: true}))
.filter(s => s.val())
.map(s => s.val())
.map(x => Object.keys(x))
.map(l => l.map(fillJob(af)))
.flatMap(os => Observable.combineLatest(...os.map(o => o.startWith(null)), list))
.map(l => l.filter(id))
.startWith([])
.map(j => j.sort((a, b) => b.timestamp - a.timestamp));
示例5: recursiveList
list(path: string): Promise<string[]> {
const recursiveList = (path: Path): Observable<Path> => this._host.list(path).pipe(
// Emit each fragment individually.
concatMap(fragments => from(fragments)),
// Join the path with fragment.
map(fragment => join(path, fragment)),
// Emit directory content paths instead of the directory path.
mergeMap(path => this._host.isDirectory(path).pipe(
concatMap(isDir => isDir ? recursiveList(path) : of(path))
)
),
);
return recursiveList(this._resolve(path)).pipe(
map(path => path.replace(this.base, '')),
toArray(),
).toPromise().then(x => x, _err => []);
}
示例6: observableOf
mergeMap((hasLoadedSession) : Observable<ICreateSessionEvent> => {
if (!hasLoadedSession) {
log.warn("EME: No data stored for the loaded session");
sessionStorage.delete(initData, initDataType);
return observableOf({
type: "created-session" as "created-session",
value: { mediaKeySession: session, sessionType },
});
}
if (hasLoadedSession && isSessionUsable(session)) {
sessionStorage.add(initData, initDataType, session);
log.info("EME: Succeeded to load persistent session.");
return observableOf({
type: "loaded-persistent-session" as "loaded-persistent-session",
value: { mediaKeySession: session, sessionType },
});
}
// Unusable persistent session: recreate a new session from scratch.
log.warn("EME: Previous persistent session not usable anymore.");
return recreatePersistentSession();
}),
示例7: concatMap
concatMap(isDir => isDir ? recursiveList(path) : of(path))
示例8: memoizeObservable
) => Observable<string> = memoizeObservable(({ owner, repoName, commitID }) =>
get<CommitResponse>(buildURL(owner, repoName, `/repository/commits/${commitID}`)).pipe(
map(({ parent_ids }) => first(parent_ids)!) // ! because it'll always have a parent if we are looking at the commit page.
)
示例9: map
({ project, repoName, commitID }) =>
get<CommitResponse>(buildURL(project, repoName, `/commits/${commitID}`)).pipe(
map(({ parents }) => first(parents)),
filter(isDefined),
map(({ id }) => id)
)