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


TypeScript selectors.model函數代碼示例

本文整理匯總了TypeScript中@nteract/selectors.model函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript model函數的具體用法?TypeScript model怎麽用?TypeScript model使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了model函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: 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

示例2: mergeMap

    mergeMap((action: ExecuteCell | ExecuteFocusedCell) => {
      if (action.type === actions.EXECUTE_FOCUSED_CELL) {
        const contentRef = action.payload.contentRef;
        const state = state$.value;
        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 id = model.cellFocused;

        if (!id) {
          throw new Error("attempted to execute without an id");
        }
        return of(
          actions.executeCell({ id, contentRef: action.payload.contentRef })
        );
      }
      return of(action);
    }),
開發者ID:kelleyblackmore,項目名稱:nteract,代碼行數:21,代碼來源:execute.ts

示例3: concatMap

    concatMap((action: ExecuteAllCells | ExecuteAllCellsBelow) => {
      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();
      }

      let codeCellIds = Immutable.List();

      if (action.type === actions.EXECUTE_ALL_CELLS) {
        codeCellIds = selectors.notebook.codeCellIds(model);
      } else if (action.type === actions.EXECUTE_ALL_CELLS_BELOW) {
        codeCellIds = selectors.notebook.codeCellIdsBelow(model);
      }
      return of(
        ...codeCellIds.map((id: CellId) =>
          actions.executeCell({ id, contentRef: action.payload.contentRef })
        )
      );
    })
開發者ID:kelleyblackmore,項目名稱:nteract,代碼行數:23,代碼來源:execute.ts


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