Last active
September 25, 2018 13:54
-
-
Save oguzgelal/844c361f09c76d1551fffd2e4c498b5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
on: 'login_submitted', | |
when: ({ event }) => isValid(event.email, event.password), | |
reaction: ({ event }) => broadcast('on_request', { | |
type: 'login', | |
path: '/api/login', | |
params: { ...event } | |
}), | |
reactionElse: () => alert('Invalid parameters'), | |
}, | |
{ | |
on: 'request_success', | |
when: ({ event }) => event.type === 'login', | |
reducer: ({ state, event }) => ({ ...state, user: event.user }), | |
reaction: () => broadcast('on_route_change', { to: 'dashboard' }) | |
}, | |
{ | |
on: 'request_fail', | |
when: ({ event }) => event.type === 'login', | |
reaction: ({ event }) => alert(`Failed: ${event.message}`) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment