本文整理汇总了TypeScript中rxjs.empty函数的典型用法代码示例。如果您正苦于以下问题:TypeScript empty函数的具体用法?TypeScript empty怎么用?TypeScript empty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了empty函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: switchMap
switchMap(sec => {
if (!sec) return empty();
const match = /^\s*([a-zA-Z]+)\.([a-zA-Z]+)\s*$/.exec(sec);
if (match) {
return this._uciModel.loadConfig(match[1]).pipe(
map(c => {
this.config = c;
this.section = c.getSection(match[2]);
}));
}
return empty();
}));
示例2: switchMap
switchMap((action: ExecuteCell) => {
const { id } = action.payload;
const state = state$.value;
const contentRef = action.payload.contentRef;
const model = selectors.model(state, { contentRef });
// If it's not a notebook, we shouldn't be here
if (!model || model.type !== "notebook") {
return empty();
}
const cell = selectors.notebook.cellById(model, {
id
});
if (!cell) {
return empty();
}
// We only execute code cells
if ((cell as any).get("cell_type") === "code") {
const source = cell.get("source", "");
const message = createExecuteRequest(source);
return createExecuteCellStream(
action$,
state,
message,
id,
action.payload.contentRef
).pipe(
catchError((error, source) =>
merge(
of(
actions.executeFailed({
error,
contentRef: action.payload.contentRef
})
),
source
)
)
);
}
return empty();
})
示例3: empty
export const getIntersectionObserver = (attributes: Attributes) => {
if (!attributes.scrollContainer && !isWindowDefined()) {
return empty();
}
const options: ObserverOptions = {
root: attributes.scrollContainer
};
if (attributes.offset) {
options.rootMargin = `${attributes.offset}px`;
}
const scrollContainer = attributes.scrollContainer || window;
let observer = observers.get(scrollContainer);
if (!observer) {
observer = new IntersectionObserver(loadingCallback, options);
observers.set(scrollContainer, observer);
}
observer.observe(attributes.element);
return Observable.create(obs => {
const subscription = intersectionSubject.pipe(filter(entry => entry.target === attributes.element)).subscribe(obs);
return () => {
subscription.unsubscribe();
observer.unobserve(attributes.element);
};
});
};
示例4: mergeMap
mergeMap((action: actions.FetchContentFulfilled) => {
const state: AppState = state$.value;
const contentRef = action.payload.contentRef;
const content = selectors.content(state, { contentRef });
if (
!content ||
content.type !== "notebook" ||
content.model.type !== "notebook"
) {
// This epic only handles notebook content
return empty();
}
const filepath = content.filepath;
const notebook = content.model.notebook;
const { cwd, kernelSpecName } = extractNewKernel(filepath, notebook);
return of(
actions.launchKernelByName({
kernelSpecName,
cwd,
kernelRef: action.payload.kernelRef,
selectNextKernel: true,
contentRef: action.payload.contentRef
})
);
})
示例5: map
map((rendition: RenditionEntry) => {
if (rendition.entry.status !== 'CREATED') {
return from(this.apiService.renditionsApi.createRendition(nodeId, { id: rendition.entry.id }));
} else {
return empty();
}
})
示例6: mergeMap
mergeMap(content => {
if (content && content.type === "notebook") {
return of(content.model.kernelRef);
} else {
return empty();
}
})
示例7: mergeMap
mergeMap((contentRef: ContentRef) => {
const state = state$.value;
const content = selectors.content(state, { contentRef });
let isVisible = false;
// document.hidden appears well supported
if (document.hidden) {
// Opera 12.10 and Firefox 18 and later support
isVisible = !document.hidden;
} else if ((document as any).msHidden) {
isVisible = !(document as any).msHidden;
} else if ((document as any).webkitHidden) {
isVisible = !(document as any).webkitHidden;
} else {
// Final fallback -- this will say the window is hidden when devtools is open or if the
// user is interacting with an iframe
isVisible = document.hasFocus();
}
if (
isVisible &&
// Don't bother saving nothing
content &&
// Only files and notebooks
(content.type === "file" || content.type === "notebook") &&
// Only save if they have a real filepath
content.filepath !== ""
) {
return of(actions.save({ contentRef }));
} else {
return empty();
}
})
示例8: flatMap
flatMap(indexes => {
switch (message.command) {
case WorkerCommand.GET_COURSES:
return of(indexes.getCourses());
case WorkerCommand.GET_TERMS:
return of(indexes.getTerms());
case WorkerCommand.GET_CURRENT_TERM:
return of(indexes.getCurrentTerm());
case WorkerCommand.GET_SECTIONS_FOR_COURSE_TERM:
return of(
indexes.getSections(message.data.course, message.data.term)
);
case WorkerCommand.GET_SEQUENCES:
return of(indexes.getSequences());
case WorkerCommand.GET_SPARSE_SEQUENCE:
return of(indexes.getSparseSequence(message.data));
case WorkerCommand.GET_DEPARTMENTS:
return of(indexes.getDepartments());
case WorkerCommand.GET_INSTRUCTORS:
return of(indexes.getInstructors());
case WorkerCommand.SEARCH:
return search(
institution,
algolia.initIndex(institution.algoliaIndex),
indexes,
message.data.transcript,
message.data.filter
);
default:
return empty();
}
})
示例9: switchMap
switchMap(action => {
if (!action.payload || typeof action.payload.filepath !== "string") {
return of({
type: "ERROR",
error: true,
payload: { error: new Error("updating content needs a payload") }
}) as any;
}
const state: any = state$.value;
const host: any = selectors.currentHost(state);
// Dismiss any usage that isn't targeting a jupyter server
if (host.type !== "jupyter") {
return empty();
}
const { contentRef, filepath, prevFilePath } = action.payload;
const serverConfig: ServerConfig = selectors.serverConfig(host);
return contents
.update(serverConfig, prevFilePath, { path: filepath.slice(1) })
.pipe(
tap(xhr => {
if (xhr.status !== 200) {
throw new Error(xhr.response);
}
}),
map(() => {
/*
* Modifying the url's file name in the browser.
* This effects back button behavior.
* Is there a better way to accomplish this?
*/
window.history.replaceState(
{},
filepath,
urljoin(host.basePath, `/nteract/edit${filepath}`)
);
return actions.changeContentNameFulfilled({
contentRef: action.payload.contentRef,
filepath: action.payload.filepath,
prevFilePath
});
}),
catchError((xhrError: any) =>
of(
actions.changeContentNameFailed({
basepath: host.basepath,
filepath: action.payload.filepath,
prevFilePath,
error: xhrError,
contentRef: action.payload.contentRef
})
)
)
);
})
示例10: it
it('should be synchronous by default', () => {
const source = empty();
let hit = false;
source.subscribe({
complete() { hit = true; }
});
expect(hit).to.be.true;
});