本文整理汇总了TypeScript中redux-observable.ofType函数的典型用法代码示例。如果您正苦于以下问题:TypeScript ofType函数的具体用法?TypeScript ofType怎么用?TypeScript ofType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ofType函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: ofType
export const updateDisplayEpic = (
action$: ActionsObservable<NewKernelAction>
) =>
// Global message watcher so we need to set up a feed for each new kernel
action$.pipe(
ofType(actions.LAUNCH_KERNEL_SUCCESSFUL),
switchMap((action: NewKernelAction) =>
action.payload.kernel.channels.pipe(
ofMessageType("update_display_data"),
map((msg: JupyterMessage) =>
actions.updateDisplay({
content: msg.content,
contentRef: action.payload.contentRef
})
),
catchError(error =>
of(
actions.updateDisplayFailed({
error,
contentRef: action.payload.contentRef
})
)
)
)
)
);
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:26,代码来源:execute.ts
示例2: ofType
const setActiveKernelEpic = (action$, state$) =>
action$.pipe(
ofType(actionTypes.SET_ACTIVE_KERNEL),
mergeMap(({ payload: { serverId, kernelName } }) => {
const channelPath = [
"entities",
"serversById",
serverId,
"server",
"activeKernelsByName",
kernelName,
"kernel",
"channel"
];
const channel = objectPath.get(state$.value, channelPath);
const actionsArray: Array<{
type: string;
payload: string | { serverId: string; kernelName: string };
}> = [actions.setCurrentKernelName(kernelName)];
if (!channel) {
actionsArray.push(actions.activateKernel({ serverId, kernelName }));
}
return of(...actionsArray);
})
);
开发者ID:nteract,项目名称:play,代码行数:26,代码来源:epics.ts
示例3: executeAllCellsEpic
export function executeAllCellsEpic(
action$: ActionsObservable<ExecuteAllCells | ExecuteAllCellsBelow>,
state$: StateObservable<AppState>
) {
return action$.pipe(
ofType(actions.EXECUTE_ALL_CELLS, actions.EXECUTE_ALL_CELLS_BELOW),
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,代码行数:31,代码来源:execute.ts
示例4: ofType
const errorHandlingEpics = action$ =>
action$.pipe(
ofType(ERROR),
delay(3000),
take(1),
map(stopError)
);
开发者ID:alex3165,项目名称:github-issues,代码行数:7,代码来源:config.ts
示例5: ofType
export const GET_TODOLIST_REQUEST = (action$: any) =>
action$.pipe(
ofType(Actions.GET_TODOLIST.REQUEST),
mergeMap((action: any) => {
const userId = getCachedUserId();
let url;
switch (action.payload.todoBoxId) {
case '@all':
url = `/t/user/${userId}/todo`;
break;
case '@task':
url = `/t/user/${userId}/task-todo`;
break;
default:
url = `/t/todo-box/${action.payload.todoBoxId}`;
break;
}
return http
.get(makeApiUrl(url))
.then((data: any) => {
return Actions.GET_TODOLIST.success(
(data || []).map((todo: any) => {
return todo.todoBoxId ? todo : { ...todo, todoBoxId: action.payload.todoBoxId };
})
);
})
.catch(Actions.GET_TODOLIST.failure);
})
);
开发者ID:A-Horse,项目名称:bblist,代码行数:30,代码来源:todo.epic.ts
示例6: ofType
export const interruptKernelEpic = (
action$: ActionsObservable<actions.InterruptKernel>,
state$: StateObservable<AppState>
) =>
action$.pipe(
ofType(actions.INTERRUPT_KERNEL),
// This epic can only interrupt kernels on jupyter websockets
filter(() => selectors.isCurrentHostJupyter(state$.value)),
// If the user fires off _more_ interrupts, we shouldn't interrupt the in-flight
// interrupt, instead doing it after the last one happens
concatMap((action: actions.InterruptKernel) => {
const state = state$.value;
const host = selectors.currentHost(state);
if (host.type !== "jupyter") {
// Dismiss any usage that isn't targeting a jupyter server
return empty();
}
const serverConfig: ServerConfig = selectors.serverConfig(host);
const kernel = selectors.currentKernel(state);
if (!kernel) {
return of(
actions.interruptKernelFailed({
error: new Error("Can't interrupt a kernel we don't have"),
kernelRef: action.payload.kernelRef
})
);
}
if (kernel.type !== "websocket" || !kernel.id) {
return of(
actions.interruptKernelFailed({
error: new Error("Invalid kernel type for interrupting"),
kernelRef: action.payload.kernelRef
})
);
}
const id = kernel.id;
return kernels.interrupt(serverConfig, id).pipe(
map(() =>
actions.interruptKernelSuccessful({
kernelRef: action.payload.kernelRef
})
),
catchError(err =>
of(
actions.interruptKernelFailed({
error: err,
kernelRef: action.payload.kernelRef
})
)
)
);
})
);
开发者ID:nteract,项目名称:nteract,代码行数:58,代码来源:websocket-kernel.ts
示例7: ofType
export const LOGOUT_SUCCESS = (action$: Observable<any>) =>
action$.pipe(
ofType(Actions.LOGOUT.SUCCESS),
mergeMap(() => {
Storage.clear();
window.location.pathname = '/';
return of(Actions.LOGOUT.finish);
})
);
开发者ID:A-Horse,项目名称:bblist,代码行数:9,代码来源:auth.epic.ts
示例8: ofType
export const CHANGE_PASSWORD_REQUEST = (action$: any) =>
action$.pipe(
ofType(Actions.CHANGE_PASSWORD.REQUEST),
mergeMap((action: any) => {
return axios
.post(makeApiUrl(`/user/update-password`), action.payload)
.then(resp => Actions.CHANGE_PASSWORD.success(resp.data))
.catch(Actions.CHANGE_PASSWORD.failure);
})
);
开发者ID:A-Horse,项目名称:bblist,代码行数:10,代码来源:user.epic.ts
示例9: ofType
export const TASKBOARD_SETTING_UPDATE_REQUEST = (action$: any) =>
action$.pipe(
ofType(Actions.TASKBOARD_SETTING_UPDATE.REQUEST),
mergeMap((action: any) => {
return axios
.patch(`/api/task-board/${action.meta.taskBoardId}/setting`, action.payload)
.then(resp => Actions.TASKBOARD_SETTING_UPDATE.success(resp.data, action.meta))
.catch(Actions.TASKBOARD_SETTING_UPDATE.failure);
})
);
开发者ID:A-Horse,项目名称:bblist,代码行数:10,代码来源:task-board.epic.ts
注:本文中的redux-observable.ofType函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论