本文整理汇总了TypeScript中@nteract/actions.clearOutputs函数的典型用法代码示例。如果您正苦于以下问题:TypeScript clearOutputs函数的具体用法?TypeScript clearOutputs怎么用?TypeScript clearOutputs使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clearOutputs函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test("clears out cell outputs", () => {
const originalState = monocellDocument;
const id = originalState.getIn(["notebook", "cellOrder"]).last();
const state = reducers(originalState, actions.clearOutputs({ id }));
expect(state.getIn(["notebook", "cellMap", id, "outputs"]).count()).toBe(0);
});
示例2: executeCellStream
export function executeCellStream(
channels: Channels,
id: string,
message: ExecuteRequest,
contentRef: ContentRef
) {
if (!channels || !channels.pipe) {
return throwError(new Error("kernel not connected"));
}
const executeRequest = message;
// All the streams intended for all frontends
const cellMessages = channels.pipe(
childOf(executeRequest),
share()
) as Observable<JupyterMessage>;
// All the payload streams, intended for one user
const payloadStream = cellMessages.pipe(payloads());
const cellAction$ = merge(
payloadStream.pipe(
map((payload: PayloadMessage) =>
actions.acceptPayloadMessage({ id, payload, contentRef })
)
),
// All actions for updating cell status
cellMessages.pipe(
kernelStatuses() as any,
map((status: string) =>
actions.updateCellStatus({ id, status, contentRef })
)
),
// Update the input numbering: `[ ]`
cellMessages.pipe(
executionCounts() as any,
map((ct: number) =>
actions.updateCellExecutionCount({ id, value: ct, contentRef })
)
),
// All actions for new outputs
cellMessages.pipe(
outputs() as any,
map((output: Output) => actions.appendOutput({ id, output, contentRef }))
),
// clear_output display message
cellMessages.pipe(
ofMessageType("clear_output") as any,
mapTo(actions.clearOutputs({ id, contentRef }))
)
);
// On subscription, send the message
return Observable.create((observer: Observer<any>) => {
const subscription = cellAction$.subscribe(observer);
channels.next(executeRequest);
return subscription;
});
}