當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript actions.clearOutputs函數代碼示例

本文整理匯總了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);
  });
開發者ID:kelleyblackmore,項目名稱:nteract,代碼行數:7,代碼來源:document.spec.ts

示例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;
  });
}
開發者ID:kelleyblackmore,項目名稱:nteract,代碼行數:64,代碼來源:execute.ts


注:本文中的@nteract/actions.clearOutputs函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。