How to use the redux-observable/lib/cjs/ActionsObservable.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 root-systems / feathers-action / test / epic.js View on Github external
test('find', function (t) {
  const cid = createCid()
  const action$ = Action$.of(cats.actions.find(cid))
  const feathers = {
    find: () => Rx.Observable.of(values(catsData))
  }
  const expected = [
    actionCreators.start(cid, { service, method: 'find', args: { params: {} } }),
    actionCreators.set(cid, 0, catsData[0]),
    actionCreators.set(cid, 1, catsData[1]),
    actionCreators.set(cid, 2, catsData[2]),
    actionCreators.complete(cid)
  ]
  cats.epic(action$, undefined, { feathers })
    .toArray() // .reduce(flip(append), [])
    .subscribe((actions) => {
      t.deepEqual(actions, expected)
      t.end()
    })
github root-systems / feathers-action / test / epic.js View on Github external
test('update', function (t) {
  const cid = createCid()
  const action$ = Action$.of(cats.actions.update(cid, 0, nextCat))
  const feathers = {
    update: () => Rx.Observable.of(merge({ id: 0, feathers: true }, nextCat))
  }
  const store = {
    getState: () => ({ cats: catsData })
  }
  const expected = [
    actionCreators.start(cid, { service, method: 'update', args: { id: 0, data: nextCat, params: {} } }),
    actionCreators.set(cid, 0, merge({ id: 0 }, nextCat)),
    actionCreators.set(cid, 0, merge({ id: 0, feathers: true }, nextCat)),
    actionCreators.complete(cid)
  ]
  cats.epic(action$, store, { feathers })
    .toArray()
    .subscribe((actions) => {
      t.deepEqual(actions, expected)
github root-systems / feathers-action / test / epic.js View on Github external
test('patch', function (t) {
  const cid = createCid()
  const action$ = Action$.of(cats.actions.patch(cid, 0, nextCat))
  const feathers = {
    patch: () => Rx.Observable.of(mergeAll([catsData[0], { feathers: true }, nextCat]))
  }
  const store = {
    getState: () => ({ cats: catsData })
  }
  const expected = [
    actionCreators.start(cid, { service, method: 'patch', args: { id: 0, data: nextCat, params: {} } }),
    actionCreators.set(cid, 0, merge(catsData[0], nextCat)),
    actionCreators.set(cid, 0, mergeAll([catsData[0], { feathers: true }, nextCat])),
    actionCreators.complete(cid)
  ]
  cats.epic(action$, store, { feathers })
    .toArray()
    .subscribe((actions) => {
      t.deepEqual(actions, expected)
github root-systems / feathers-action / test / epic.js View on Github external
test('create with rollback', function (t) {
  const cid = createCid()
  const err = new Error('oh no')
  const action$ = Action$.of(cats.actions.create(cid, newCat))
  const feathers = {
    create: () => Rx.Observable.throw(err)
  }
  const expected = [
    actionCreators.start(cid, { service, method: 'create', args: { data: newCat, params: {} } }),
    actionCreators.set(cid, cid, newCat),
    actionCreators.set(cid, cid, undefined),
    actionCreators.error(cid, err)
  ]
  cats.epic(action$, undefined, { feathers })
    .toArray()
    .subscribe((actions) => {
      t.deepEqual(actions, expected)
      t.end()
    })
})
github root-systems / feathers-action / test / epic.js View on Github external
test('remove', function (t) {
  const cid = createCid()
  const action$ = Action$.of(cats.actions.remove(cid, 0))
  const feathers = {
    remove: () => Rx.Observable.of(catsData[0])
  }
  const store = {
    getState: () => ({ cats: catsData })
  }
  const expected = [
    actionCreators.start(cid, { service, method: 'remove', args: { id: 0, params: {} } }),
    actionCreators.set(cid, 0, undefined),
    actionCreators.set(cid, 0, undefined),
    actionCreators.complete(cid)
  ]
  cats.epic(action$, store, { feathers })
    .toArray()
    .subscribe((actions) => {
      t.deepEqual(actions, expected)
github root-systems / feathers-action / test / epic.js View on Github external
test('get', function (t) {
  const cid = createCid()
  const action$ = Action$.of(cats.actions.get(cid, 0))
  const feathers = {
    get: (id) => Rx.Observable.of(catsData[id])
  }
  const expected = [
    actionCreators.start(cid, { service, method: 'get', args: { id: 0, params: {} } }),
    actionCreators.set(cid, 0, catsData[0]),
    actionCreators.complete(cid)
  ]
  cats.epic(action$, undefined, { feathers })
    .toArray()
    .subscribe((actions) => {
      t.deepEqual(actions, expected)
      t.end()
    })
})