本文整理匯總了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;
});
}