From the course: Node.js: Design Patterns

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Implementing decorators

Implementing decorators - Node.js Tutorial

From the course: Node.js: Design Patterns

Implementing decorators

- [Instructor] In the last lesson, we defined the decorator pattern, as well as added a couple of decorator classes to some existing code. I'm looking at the exercise files found under Chapter Three, Lesson Eight, within the Start folder. We added the GoldenInventoryItem and DiamondInventoryItem to this index.js file, and we also created golden necklaces, A Diamond Gold Necklace, and a Diamond Walkman. In this lesson, we need to actually write the code for the GoldenInventoryItem and DiamondInventoryItem decorator classes. So let's go ahead and open up our inventory item file. So we'll go ahead and add the decorators right here, next to the InventoryItem. So I'm going to go ahead and add a class GoldenInventoryItem, and a class for DiamondInventoryItem, and we're just going to export all three of these things together within the same object, so I'll make sure that I export my GoldenInventoryItem class and…

Contents