Last active
January 9, 2019 19:39
-
-
Save shalvah/c39e74b29aefc4f18ce661c9c1543d51 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// the base command class or interface | |
class Command { | |
handle() { | |
} | |
} | |
class CreateUserCommand extends Command { | |
constructor(user) { | |
super(); | |
this.user = user; | |
} | |
handle() { | |
// create the user in the db | |
} | |
} | |
const createUser = new CreateUserCommand(user); | |
// dispatch the command - this calls the handle() method | |
dispatch(createUser); | |
// or you could use a CommandHandler class | |
commandHandler.handle(createUser); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment