salsita / redux-saga-rxjs

RxJS implementation of Saga pattern for redux
112 stars 5 forks source link

unknown type returned #4

Closed thorbenandresen closed 8 years ago

thorbenandresen commented 8 years ago

Hi,

this here works for me

export const saga = iterable => iterable
  .filter(({ action, state }) => action.type === 'FOO')
  .map(() => ({type: 'BAR'}))

this here does not work

export const saga = iterable => iterable
  .filter(({ action, state }) => action.type === 'FOO')
  .flatMap(() => Observable
    .fromPromise(AsyncStorage.getItem('items'))
    .map(items => ({type: 'BAR', data: items})))

screen shot 2016-03-20 at 8 16 17 pm

I am still trying to wrap my head around sagas+rx, but based on this example it should work, right?

tomkis commented 8 years ago

Hello @Thorbenandresen,

Your example does indeed seems correct to me.

export default iterable => iterable
  .filter(({ action, state }) => action.type === 'Boot')
  .flatMap(() => Observable
    .fromPromise(new Promise(res => res()))
    .map(() => ({type: 'BAR', data: []})));

Here's my code which WFM.

Maybe you could provide more complete example?

thorbenandresen commented 8 years ago

@tomkis1 - thanks, I found my mistake. I was using import {Observable} from 'rx' instead of import {Observable} from 'rxjs'. (importing from 'rx' works in my thunks where I use Observables, thats why I was misled) Sorry for that!