课程: Node.js: Design Patterns

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Implementing commands

Implementing commands

- [Instructor] In the last lesson we introduced the command pattern and we saw how we can incorporate that pattern into an already existing node app that implemented a read line interface. In this lesson, we're going to implement the conductor that we're importing, as well as each command class that we're importing online, too. So I'm in the exercise files, under chapter four lesson four, within the start folder. And I'm going to go ahead and create a new file called commands.js. And I'm going to go ahead and put all of my command classes within this file. So we're going to need to create a class for the exit command and we're also going to need to create one for create command. And then I'm just going to make sure that I export both of these. Great, so now we have both classes and we're ready to export them. Let's go ahead and write the code for our exit command. So I'm going to write a getter to get the name of this…

内容