Skip to content

Instantly share code, notes, and snippets.

@kvasdopil
Last active December 9, 2015 15:10
Show Gist options
  • Save kvasdopil/66be0d29ac44ca79eb83 to your computer and use it in GitHub Desktop.
Save kvasdopil/66be0d29ac44ca79eb83 to your computer and use it in GitHub Desktop.
// == actions.js ==
function showModal(id, cb)
{
return {type: 'SHOW_MODAL', id, cb: (ok) => {
closeModal(id); // dispatch here?
if(ok) cb();
}};
}
function closeModal(id)
{
return {type: 'CLOSE_MODAL', id}
}
// == myModule.js ==
@Connected
class MyModule
{
onClickButton() {
this.props.actions.showModal('myModal', () => {
console.log('window is closed');
});
}
render()
{
return <Modal {...this.props.store.modals.myModal} >...</Modal>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment