How to use the redux-observable.StateObservable function in redux-observable

To help you get started, we’ve selected a few redux-observable examples, based on popular ways it is used in public projects.

github zeit / next.js / examples / with-redux-observable / pages / index.js View on Github external
static async getInitialProps({ store, isServer }) {
    const state$ = new StateObservable(new Subject(), store.getState())
    const resultAction = await rootEpic(
      of(actions.fetchCharacter(isServer)),
      state$
    ).toPromise() // we need to convert Observable to Promise
    store.dispatch(resultAction)

    return { isServer }
  }
github nteract / nteract / packages / epics / __tests__ / contents.spec.ts View on Github external
})
            )
          }),
          transforms: makeTransformsRecord({
            displayOrder: Immutable.List([]),
            byId: Immutable.Map({})
          })
        })
      })
    };

    const responses = await saveAsContentEpic(
      ActionsObservable.of(
        actions.saveAs({ filepath: "test.ipynb", contentRef })
      ),
      new StateObservable(new Subject(), state)
    )
      .pipe(toArray())
      .toPromise();

    expect(responses).toEqual([
      actions.saveAsFailed({
        contentRef,
        error: new Error("Cannot save content if no host is set.")
      })
    ]);
  });
  it("does not save if there is no content", async () => {
github nteract / nteract / packages / epics / __tests__ / websocket-kernel.spec.ts View on Github external
test("can interrupt a kernel when given a content ref", async () => {
    const state$ = new StateObservable(new Subject<stateModule.AppState>(), {
      core: stateModule.makeStateRecord({
        entities: stateModule.makeEntitiesRecord({
          kernels: stateModule.makeKernelsRecord({
            byRef: Immutable.Map({
              fakeKernelRef: stateModule.makeRemoteKernelRecord({
                type: "websocket",
                channels: new Subject<any>(),
                kernelSpecName: "fancy",
                id: "0"
              })
            })
          }),
          contents: stateModule.makeContentsRecord({
            byRef: Immutable.Map({
              contentRef: stateModule.makeNotebookContentRecord({
                model: stateModule.makeDocumentRecord({
github nteract / nteract / packages / epics / __tests__ / websocket-kernel.spec.ts View on Github external
test("respects output handling for running all cells", async () => {
    const state$ = new StateObservable(new Subject<stateModule.AppState>(), {
      core: stateModule.makeStateRecord({
        kernelRef: "fake",
        entities: stateModule.makeEntitiesRecord({
          kernels: stateModule.makeKernelsRecord({
            byRef: Immutable.Map({
              fake: stateModule.makeRemoteKernelRecord({
                type: "websocket",
                channels: new Subject<any>(),
                kernelSpecName: "fancy",
                id: "0"
              })
            })
          })
        })
      }),
      app: stateModule.makeAppRecord({
github nteract / nteract / packages / epics / __tests__ / kernel-lifecycle.spec.ts View on Github external
})
      }),
      app: stateModule.makeAppRecord({
        notificationSystem: { addNotification: () => {} }
      })
    };

    const responses = await restartKernelEpic(
      ActionsObservable.of(
        actionsModule.restartKernel({
          outputHandling: "Run All",
          kernelRef: "oldKernelRef",
          contentRef: "contentRef"
        })
      ),
      new StateObservable(new Subject(), state)
    )
      .pipe(toArray())
      .toPromise();

    expect(responses).toEqual([]);
  });
});
github nteract / nteract / packages / epics / __tests__ / websocket-kernel.spec.ts View on Github external
})
          }),
          kernels: stateModule.makeKernelsRecord({
            byRef: Immutable.Map({
              fake: stateModule.makeRemoteKernelRecord({
                type: "websocket",
                channels: new Subject<any>(),
                kernelSpecName: "fancy",
                id: "0"
              })
            })
          })
        })
      })
    };
    const state$ = new StateObservable(
      new Subject<stateModule.AppState>(),
      value
    );
    const action$ = ActionsObservable.of(
      actions.launchKernelByName({
        contentRef,
        kernelRef,
        kernelSpecName: "fancy",
        cwd: "/",
        selectNextKernel: true
      })
    );

    const responseActions = await coreEpics
      .launchWebSocketKernelEpic(action$, state$)
      .pipe(toArray())
github nteract / nteract / packages / epics / __tests__ / contents.spec.ts View on Github external
})
            )
          }),
          transforms: makeTransformsRecord({
            displayOrder: Immutable.List([]),
            byId: Immutable.Map({})
          })
        })
      })
    };

    const responses = await saveContentEpic(
      ActionsObservable.of(
        actions.save({ filepath: "test.ipynb", contentRef })
      ),
      new StateObservable(new Subject(), state)
    )
      .pipe(toArray())
      .toPromise();

    expect(responses).toEqual([
      actions.saveFulfilled({
        contentRef,
        model: { last_modified: "one_value" }
      }),
      actions.saveFulfilled({
        contentRef,
        model: { last_modified: "some_stable_value" }
      })
    ]);
  });
});
github myungjaeyu / nextjs-starter / pages / redux / profile.js View on Github external
static async getInitialProps (pageProps) {

        const { store } = pageProps

        const store$ = new StateObservable(new Subject(), store.getState())

        const action = await epics(
                                of(fetchGithub()),
                                store$
                            )
                            .toPromise()

        store.dispatch(action)

        return { }

    }