redux-utilities / redux-promise

FSA-compliant promise middleware for Redux.
MIT License
2.67k stars 134 forks source link

Action args when using promise middleware #5

Closed taion closed 8 years ago

taion commented 9 years ago

Regarding: https://github.com/acdlite/redux-promise/blob/v0.4.0/src/index.js#L15-L20

I was working through a problem that looked like it might have been handled by this, but am having this issue - in pseudocode that corresponds to no specific Flux framework, I'm doing something like:

updateFoo(id) {
  FooUtils.updateFoo(id).then(
    result => this.dispatch(UPDATE_FOO_SUCCESS, {id, result}),
    error => this.dispatch(UPDATE_FOO_ERROR, {id, error})
  );
}

In principle with something like the promise middleware, I ought to be able to do something like:

updateFoo(id) {
  this.dispatch(UPDATE_FOO, FooUtils.updateFoo(id));
}

but that's not quite sufficient if I want to pass through the id field - it might have to be something like

updateFoo(id) {
  this.dispatch(UPDATE_FOO, FooUtils.updateFoo(id).then(
    result => {id, result},
    error => throw {id, error}
  );
}

which seems a bit verbose.

Sorry if this is a bit rambly - am I just missing something obvious here?

taion commented 8 years ago

I don't remember what I was trying to get at here any more.