rpominov / fluce

[DEPRECATED] Flux with immutable data and pure action handlers
MIT License
75 stars 1 forks source link

Should we give action creators only `dispatch` function instead of whole `fluce` instance? #6

Closed rpominov closed 9 years ago

rpominov commented 9 years ago

... and remove dispatch method from fluce, so only registered action creators could dispatch.

Both features provide more flexibility because 1) action creators can read from fluce.stores 2) one can dispatch an action directly, without using an action creator. But are these good patterns?

For the clarification of what is proposed:

// now
fluce.addActionCreator(fluce => {
  return (some, args) => {
    // can read `fluce.stores` here
    fluce.dispatch('someAction', {some: payload})
  }
})

// proposed
fluce.addActionCreator(dispatch => {
  return (some, args) => {
    dispatch('someAction', {some: 'payload'})
  }
})
// now: one can _dispathc_ an action directly outside of an action creator 
fluce.dispathc('someAction', {some: 'payload'})

// proposed
fluce.dispathc === undefined
rpominov commented 9 years ago

In case one need to read from fluce.stores in action creator, she can do it in code that calls the creator:

fluce.actions.someActionCreator(fluce.stores.someStore.someData, anotherArgument)
rpominov commented 9 years ago

.addActionCreator() now removed (see #7)