Redux-observable: Docs should make it more clear redux-observable questions are likely RxJS questions

Created on 25 Mar 2017  路  4Comments  路  Source: redux-observable/redux-observable

Note: this is not in response to anyone in particular who recently asked questions 馃槃 I see this all. the. time.


I keep seeing a common pattern of redux-observable users asking "how do I" questions under the context of redux-observable but in fact, 99% of the time they are just general RxJS questions. Which means they could find help/answers easier if they generalized the question or asked in normal Rx help channels.

We should try to make this excruciatingly clear, perhaps giving some examples. This will make finding help easier but also makes it much more obvious that they are learning a skill that is not redux-observable specific! They can and should apply that skill elsewhere and think of redux-observable as RxJS-first, redux second.

e.g. "How do I dispatch two actions sequentially?" -> "How do I emit two things sequentially?"

// Instead of asking and learning this

const somethingEpic = action$ =>
  action$.ofType(SOMETHING)
    .mergeMap(action =>
      Observable.of(
        action1(action.payload),
        action2(action.payload)
      )
    );

// Learn this, which will teach you about it generally

Observable.of(1, 2)
  .mergeMap(value =>
    Observable.of(value * 10, value * 20)
  )
  .subscribe(value => console.log(value));

// Then you can think of things like this
// it's just Rx!

Observable.of({ type: 'SOMETHING', value: 1 })
  .mergeMap(action =>
    Observable.of({
      type: 'FIRST',
      value: action.value
    }, {
      type: 'SECOND',
      value: action.value
    })
  )
  .subscribe(action => console.log(action));

I think this is key. Stop thinking about redux-observable as a library that happens to use RxJS and instead think of it as using RxJS that happens to use redux.

Most helpful comment

Imho, a good idea could be to add a recipe called "getting things complicated" where to explain that most of the things in an epic can be done by combining observables and their operators. You may suggest which operators to study to get things like:

  • emit multiple actions
  • perform multiple ajax calls
  • interact with websocket
  • interact with external libs
    Then suggest the main channels for ask about rxjs for more.
    I think a couple of examples about the use cases above makes the lib even more inviting and help users to get started.

All 4 comments

So very yes.

I recommend a massive advertising spend. Blanket the airwaves. "HAVE YOU SEEN THIS PATTERN?" on milk cartons.

Go big or go home.

Imho, a good idea could be to add a recipe called "getting things complicated" where to explain that most of the things in an epic can be done by combining observables and their operators. You may suggest which operators to study to get things like:

  • emit multiple actions
  • perform multiple ajax calls
  • interact with websocket
  • interact with external libs
    Then suggest the main channels for ask about rxjs for more.
    I think a couple of examples about the use cases above makes the lib even more inviting and help users to get started.

Hello, I just started using redux-observable with no prior knowledge of rxjs and I agree with this, I think it needs to be stressed more as sometimes it's not clear if my issue is with redux-observable or with rxjs.. almost always the latter however..

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MaximeBernard picture MaximeBernard  路  6Comments

mohandere picture mohandere  路  6Comments

pawelotto picture pawelotto  路  3Comments

MikeRyanDev picture MikeRyanDev  路  3Comments

winkerVSbecks picture winkerVSbecks  路  4Comments