本文整理汇总了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)
)