You are looking at the old Apostrophe 0.5 documentation. It is deprecated for new projects. Check out the latest version!

Allowing others to subclass your module

← Previous: Subclassing well-behaved modules

Some tips on writing modules that are friendly to subclassing:

  • Don't cheat! Follow the pattern. Your module must have a constructor, which should be attached to the function that your module exports as the Construct property.

  • At the end of your constructor, always make sure callback exists before invoking it. When subclasses are present, they will pass you a null callback and invoke it themselves.

  • Make sure you add defaults to the options object without crushing whatever is already there. Sometimes it's more appropriate to append.

Next: Preparing your module for npm →