JSPM

voltron-hooks

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q6933F
  • License MIT

A helper package for adding lifecycle hooks before or after method calls on an object.

Package Exports

  • voltron-hooks

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (voltron-hooks) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status

VoltronHooks allows you to add async, promise based lifecycle hooks (before/after calls) to any method that returns a promise:

  • beforeHooks are executed before a method call
  • afterHooks are executed after a method call
  • errors in before hooks prevent execution of the called method
  • beforeHooks return the original method's promise; after hooks return a promise from the hook itself

VoltronHooks are used by VoltronModels and VoltronAdapters to add methods like beforeSave, beforeUpdate, afterCreate, etc. But VoltronHooks can be applied to any object, independent of whether other Voltron components are used.