Last active
January 21, 2020 09:32
-
-
Save nesterone/d3596c8c5d1cecb6bedc763c84975243 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
export class CreatePostCommand extends Command { | |
/** | |
* Creates a command for adding new post to the system, | |
* @param {Posts} posts - posts in system | |
*/ | |
constructor(posts) { | |
super(); | |
this.posts = posts; | |
} | |
/** | |
* Creates new post in system | |
* @param {Post} post - new post not yet added to system | |
* @param {string} id - id of newly created post | |
*/ | |
async execute(post) { | |
post = await this.posts.add(post); | |
return post.id(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment