Skip to content

Commit

Permalink
Dispatching actions with action creators
Browse files Browse the repository at this point in the history
  • Loading branch information
goatslacker committed Sep 27, 2015
1 parent 6fb1603 commit cd54ed1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/alt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ class Alt {
dispatch(action, data, details) {
this.batchingFunction(() => {
const id = Math.random().toString(18).substr(2, 16)

if (action.id && action.dispatch) {
const dispatchData = action.dispatch(data)
if (dispatchData === undefined) return

const actionId = action.id
const namespace = actionId
const name = actionId
return this.dispatcher.dispatch({
id,
action: actionId,
data: action.dispatch(data),
details: {
id: actionId,
namespace,
name,
}
})
}

return this.dispatcher.dispatch({
id,
action,
Expand Down
1 change: 1 addition & 0 deletions src/alt/store/AltStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class AltStore {
}
this.state = state

this.alt = alt
this.preventDefault = false
this.displayName = model.displayName
this.boundListeners = model.boundListeners
Expand Down

0 comments on commit cd54ed1

Please sign in to comment.