本文整理汇总了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();
}));
开发者ID:ianchi,项目名称:luci-ng,代码行数:15,代码来源:section.component.ts
示例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();
})
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:48,代码来源:execute.ts
示例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);
};
});
};
开发者ID:tjoskar,项目名称:ng2-lazyload-image,代码行数:31,代码来源:intersection-listener.ts
示例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
})
);
})
开发者ID:nteract,项目名称:nteract,代码行数:31,代码来源:kernel-lifecycle.ts
示例5: map
map((rendition: RenditionEntry) => {
if (rendition.entry.status !== 'CREATED') {
return from(this.apiService.renditionsApi.createRendition(nodeId, { id: rendition.entry.id }));
} else {
return empty();
}
})
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:7,代码来源:renditions.service.ts
示例6: mergeMap
mergeMap(content => {
if (content && content.type === "notebook") {
return of(content.model.kernelRef);
} else {
return empty();
}
})
开发者ID:nteract,项目名称:nteract,代码行数:7,代码来源:native-window.ts
示例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();
}
})
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:34,代码来源:contents.ts
示例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();
}
})
开发者ID:kevmo314,项目名称:canigraduate.uchicago.edu,代码行数:32,代码来源:indexes-worker.ts
示例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
})
)
)
);
})
开发者ID:nteract,项目名称:nteract,代码行数:59,代码来源:contents.ts
示例10: it
it('should be synchronous by default', () => {
const source = empty();
let hit = false;
source.subscribe({
complete() { hit = true; }
});
expect(hit).to.be.true;
});
开发者ID:DallanQ,项目名称:rxjs,代码行数:8,代码来源:empty-spec.ts
注:本文中的rxjs.empty函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论