How to use the redux-observable.ActionsObservable.of 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.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nteract / nteract / packages / epics / __tests__ / execute.spec.ts View on Github external
// Should not be processed
      {
        header: { msg_type: "ignored" },
        content: { data: { "text/html": "<marquee>wee</marquee>" } }
      },
      {
        header: { msg_type: "update_display_data" },
        content: {
          data: { "text/plain": "i am text" },
          transient: { display_id: "here" }
        }
      }
    ];

    const channels = from(messages);
    const action$ = ActionsObservable.of({
      type: actions.LAUNCH_KERNEL_SUCCESSFUL,
      payload: {
        kernel: {
          channels,
          cwd: "/home/tester",
          type: "websocket"
        },
        kernelRef: "fakeKernelRef",
        contentRef: "fakeContentRef",
        selectNextKernel: false
      }
    });

    const epic = updateDisplayEpic(action$);

    const responseActions = [];
github lmatteis / redux-tdd / src / redux-tdd.js View on Github external
epic(epicFn, dependencies) {
    const action$ = ActionsObservable.of(this.currentAction);
    const store = {
      getState: () => this.state
    };

    epicFn(action$, store, dependencies)
      .toArray() // buffers all emitted actions until your Epic naturally completes()
      .subscribe(actions => {
        // only run automatically the first one
        actions.forEach((action, idx) =>
          idx === 0 && this.action(() => action)
        );
        actions.shift()
        this.epicActions = actions;
      });

    return this;
github nteract / nteract / applications / desktop / __tests__ / renderer / epics / git-spec.js View on Github external
byRef: Immutable.Map({
                "123": makeNotebookContentRecord()
              })
            },
            kernels: {
              byRef: Immutable.Map({
                k1: {}
              })
            }
          }
        }
      })
    };

    await gitInitEpic(
      ActionsObservable.of(actions.gitInit({ contentRef })),
      store
    )
      .pipe(toArray())
      .subscribe(actions => {
        expect(actions).to.deep.equal([
          actions.gitInitSuccessful({ contentRef })
        ]);
        done();
      });
  });
});
github nteract / nteract / applications / desktop / __tests__ / renderer / epics / loading.spec.ts View on Github external
test("errors when file cant be read", async () => {
    const action$ = ActionsObservable.of({
      type: "CORE/FETCH_CONTENT",
      payload: { filepath: "file" }
    });

    const responseActions = await fetchContentEpic(action$)
      .pipe(toArray())
      .toPromise();

    expect(responseActions).toEqual([
      {
        payload: {
          error: expect.anything(),
          filepath: "file"
        },
        error: true,
        type: "CORE/FETCH_CONTENT_FAILED"
github choonchernlim / front-end-stack / src / js / app / epics / __tests__ / getJokeEpic-spec.js View on Github external
it('given failed call, should return joke failed action', () => {
        const action$ = ActionsObservable.of(actions.getJoke());
        const apis = {
          getJokeApi: () => throwError({
            message: 'test',
          }),
        };

        getJokeEpic(action$, null, apis)
          .pipe(toArray())
          .subscribe(actualActions => expect(actualActions).to.deep.equal([
            actions.getJokeFailed('test'),
          ]));
      });
    });
github nteract / nteract / packages / epics / __tests__ / kernel-lifecycle.spec.ts View on Github external
contentRef: stateModule.makeNotebookContentRecord({
                model: stateModule.makeDocumentRecord({
                  kernelRef: "oldKernelRef"
                })
              })
            })
          })
        })
      }),
      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__ / execute.spec.ts View on Github external
kernels: stateModule.makeKernelsRecord({
              byRef: Immutable.Map({
                fake: stateModule.makeRemoteKernelRecord({
                  channels,
                  status: "not connected"
                })
              })
            })
          })
        }),
        app: {
          notificationSystem: { addNotification: jest.fn() }
        }
      }
    };
    const action$ = ActionsObservable.of(
      actions.sendExecuteRequest({
        id: "id",
        message: "test",
        contentRef: "fakeContentRef"
      })
    );
    const observable = createExecuteCellStream(
      action$,
      state$.value,
      createMessage("execute_request"),
      "id",
      "fakeContentRef"
    );
    observable.pipe(toArray()).subscribe(
      actions => {
        const errors = actions.map(({ payload: { error } }) =>
github nteract / nteract / packages / core / __tests__ / epics / websocket-kernel-spec.js View on Github external
})
            })
          })
        }),
        app: stateModule.makeAppRecord({
          host: stateModule.makeJupyterHostRecord({
            type: "jupyter",
            token: "eh",
            serverUrl: "http://localhost:8888/"
          }),
          notificationSystem: { addNotification: jest.fn() }
        })
      }
    };

    const action$ = ActionsObservable.of(actions.interruptKernel({}));

    const responseActions = await coreEpics
      .interruptKernelEpic(action$, store)
      .pipe(toArray())
      .toPromise();

    expect(responseActions).toEqual([
      {
        type: "INTERRUPT_KERNEL_SUCCESSFUL",
        payload: {}
      }
    ]);
  });
});
github nteract / nteract / packages / epics / __tests__ / comm.spec.ts View on Github external
data: "DATA",
        metadata: "0",
        comm_id: "0123",
        target_name: "daredevil",
        target_module: "murdock"
      },
      buffers: new Uint8Array([])
    };

    const commMessage = {
      header: { msg_type: "comm_msg" },
      content: { data: "DATA", comm_id: "0123" },
      buffers: new Uint8Array([])
    };

    const action = ActionsObservable.of(
      actions.launchKernelSuccessful({
        kernel: {
          channels: of(commOpenMessage, commMessage) as Subject,
          cwd: "/home/tester",
          type: "websocket"
        },
        kernelRef: "fakeKernelRef",
        contentRef: "fakeContentRef",
        selectNextKernel: false
      })
    );

    commListenEpic(action)
      .pipe(toArray())
      .subscribe(
        actions =&gt; {
github nteract / nteract / applications / desktop / __tests__ / renderer / epics / git-spec.js View on Github external
byRef: Immutable.Map({
                "123": makeNotebookContentRecord()
              })
            },
            kernels: {
              byRef: Immutable.Map({
                k1: {}
              })
            }
          }
        }
      })
    };

    await gitAddEpic(
      ActionsObservable.of(actions.gitAdd({ contentRef })),
      store
    )
      .pipe(toArray())
      .subscribe(actions => {
        expect(actions).to.deep.equal([
          actions.gitAddSuccessful({ contentRef })
        ]);
        done();
      });
  });
});