Rename action param -> data in examples
This commit is contained in:
@@ -10,12 +10,12 @@ const app = choo({
|
||||
const send = createSend('onError: ')
|
||||
send('app:error', err)
|
||||
},
|
||||
onAction: function (action, state, name, caller, createSend) {
|
||||
onAction: function (data, state, name, caller, createSend) {
|
||||
console.groupCollapsed(`Action: ${caller} -> ${name}`)
|
||||
console.log(action)
|
||||
console.log(data)
|
||||
console.groupEnd()
|
||||
},
|
||||
onState: function (action, state, prev, createSend) {
|
||||
onState: function (data, state, prev, createSend) {
|
||||
console.groupCollapsed('State')
|
||||
console.log(prev)
|
||||
console.log(state)
|
||||
|
||||
@@ -6,13 +6,13 @@ module.exports = {
|
||||
title: 'Button pushing machine 3000'
|
||||
},
|
||||
reducers: {
|
||||
set: (action, state) => ({ 'title': action.data })
|
||||
set: (data, state) => ({ 'title': data })
|
||||
},
|
||||
effects: {
|
||||
good: function (action, state, send, done) {
|
||||
good: function (data, state, send, done) {
|
||||
request('/good', send, done)
|
||||
},
|
||||
bad: (action, state, send, done) => request('/bad', send, done)
|
||||
bad: (data, state, send, done) => request('/bad', send, done)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,6 @@ function request (uri, send, done) {
|
||||
return done(new Error(message))
|
||||
}
|
||||
if (!body) return done(new Error('fatal: no body received'))
|
||||
send('api:set', { data: body.message || body.title }, done)
|
||||
send('api:set', body.message || body.title, done)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,13 +15,13 @@ module.exports = {
|
||||
triggerTime: null
|
||||
},
|
||||
reducers: {
|
||||
setError: function (action, state) {
|
||||
setError: function (data, state) {
|
||||
return {
|
||||
errors: state.errors.concat(action.message),
|
||||
errorTimeDone: action.errorTimeDone
|
||||
errors: state.errors.concat(data.message),
|
||||
errorTimeDone: data.errorTimeDone
|
||||
}
|
||||
},
|
||||
'delError': function (action, state) {
|
||||
'delError': function (data, state) {
|
||||
state.errors.shift()
|
||||
return { errors: state.errors }
|
||||
}
|
||||
|
||||
@@ -35,13 +35,13 @@ function createModel () {
|
||||
}
|
||||
],
|
||||
reducers: {
|
||||
'print': (action, state) => {
|
||||
return ({ msg: state.msg + ' ' + action.payload })
|
||||
'print': (data, state) => {
|
||||
return ({ msg: state.msg + ' ' + data.payload })
|
||||
}
|
||||
},
|
||||
effects: {
|
||||
close: () => stream.close(),
|
||||
error: (action, state) => console.error(`error: ${action.payload}`)
|
||||
error: (data, state) => console.error(`error: ${data.payload}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ app.model({
|
||||
title: 'my demo app'
|
||||
},
|
||||
reducers: {
|
||||
update: (action, state) => ({ title: action.payload })
|
||||
update: (data, state) => ({ title: data.payload })
|
||||
},
|
||||
effects: {
|
||||
update: (action, state, send) => (document.title = action.payload)
|
||||
update: (data, state, send) => (document.title = data.payload)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user