Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
})
),
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 of(actions.sendExecuteRequest());
}
return empty();
})
);
return empty();
}
const cell = selectors.notebook.cellById(model, { id });
if (!cell) {
return empty();
}
// We only execute code cells
if (cell.get("cell_type") !== "code") {
return empty();
}
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
})
),
byRef: Immutable.Map({
fake: stateModule.makeRemoteKernelRecord({
channels,
status: "connected"
})
})
})
})
}),
app: {
notificationSystem: { addNotification: jest.fn() }
}
}
};
const action$ = ActionsObservable.from([]);
const message = createExecuteRequest("source");
const observable = createExecuteCellStream(
action$,
state$.value,
message,
"id"
);
const actionBuffer = [];
observable.subscribe(x => actionBuffer.push(x), err => done.fail(err));
expect(actionBuffer).toEqual([
actions.sendExecuteRequest({ id: "id", message })
]);
done();
});
});
byRef: Immutable.Map({
fake: stateModule.makeRemoteKernelRecord({
channels,
status: "connected"
})
})
})
})
}),
app: {
notificationSystem: { addNotification: jest.fn() }
}
}
};
const action$ = ActionsObservable.from([]);
const message = createExecuteRequest("source");
const observable = createExecuteCellStream(
action$,
state$.value,
message,
"id",
"fakeContentRef"
);
const actionBuffer = [];
observable.subscribe(x => actionBuffer.push(x), err => done.fail(err));
expect(actionBuffer).toEqual([
actions.sendExecuteRequest({
id: "id",
message,
contentRef: "fakeContentRef"
})