Slide 13
Slide 13 text
const app = syntagme()
app.reducer(({ action }, state = {}) => {
switch (actio.type) {
case 'FETCH':
return _.defaults({ message: null }, state)
case 'FETCH_RESOLVE':
return _.defaults({ message: action.message }, state)
case 'FETCH_REJECT':
return _.defaults({ error: action.rejection }, state)
}
})
app.listen()
app.subscribe((state) => {
console.log('state', state)
})
app.ac('FETCH', () => {
return http.get('/api/messages/greeting')
.then(({ body }) => { return { message: body.message } })
})