Skip to content

Commit

Permalink
switch to fetchContentFulfilled
Browse files Browse the repository at this point in the history
  • Loading branch information
rgbkrk committed Feb 15, 2018
1 parent 12ecaea commit 05dd87b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
5 changes: 3 additions & 2 deletions applications/desktop/src/notebook/epics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import {
executeCellEpic,
updateDisplayEpic,
commListenEpic,
executeAllCellsEpic
executeAllCellsEpic,
// TODO: Integration of the following epics
// launchKernelWhenNotebookSetEpic
// setNotebookEpic
setNotebookEpic
} from "@nteract/core/epics";

import { publishEpic } from "./github-publish";
Expand All @@ -43,6 +43,7 @@ export const wrapEpic = (epic: Epic<*, *, *>) => (...args: any) =>
epic(...args).pipe(catchError(retryAndEmitError));

const epics = [
setNotebookEpic,
executeAllCellsEpic,
restartKernelEpic,
watchSpawn,
Expand Down
29 changes: 25 additions & 4 deletions applications/desktop/src/notebook/epics/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import * as fs from "fs";

import { of } from "rxjs/observable/of";
import { forkJoin } from "rxjs/observable/forkJoin";
import { map, tap, mergeMap, switchMap, catchError } from "rxjs/operators";
import {
map,
tap,
mergeMap,
switchMap,
catchError,
timeout
} from "rxjs/operators";

import { ActionsObservable, ofType } from "redux-observable";

Expand Down Expand Up @@ -135,8 +142,22 @@ export const loadEpic = (action$: ActionsObservable<*>) =>
// Project onto the Contents API response
(content, stat) => createContentsResponse(filepath, stat, content)
).pipe(
// TODO: Switch this all to a response to fetchContents instead
// and handle accordingly
// Timeout after one minute
timeout(60 * 1000),
map(model =>
actions.fetchContentFulfilled({
path: model.filepath,
model
})
),
catchError((err: Error) =>
of(actions.fetchContentFailed({ path: filepath, error: err }))
)
);
})
);

/*
map(({ content, filePath }) => convertRawNotebook(filePath, content)),
mergeMap(({ filename, notebook }) => {
const { cwd, kernelSpecName } = extractNewKernel(filename, notebook);
Expand All @@ -151,7 +172,7 @@ export const loadEpic = (action$: ActionsObservable<*>) =>
catchError(err => of({ type: "ERROR", payload: err, error: true }))
);
})
);
);*/

/**
* Sets a new empty notebook.
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/epics/contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export function saveContentEpic(
}

// When content gets loaded, if it's a notebook, set it up as the notebook
// TODO: should this be renamed as "fetchContentFulfilledEpic"
export function setNotebookEpic(
action$: ActionsObservable<*>,
store: Store<*, *>
Expand Down

0 comments on commit 05dd87b

Please sign in to comment.