Skip to content

Commit

Permalink
Add documentation about promises and hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
tilgovi committed Apr 25, 2015
1 parent 7f1c481 commit ef76e8d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions doc/module-development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,20 @@ modules directly from the namespace::
Module hooks
------------

This is a list of module hooks, when they are called, and what arguments they
receive.
Hooks are called by the application in order to delegate work to registered
modules. This is a list of module hooks, when they are called, and what
arguments they receive.

It is possible to add your own hooks to your application by invoking the
:func:`~annotator.App.prototype.runHook` method on the application instance.
The return value is a :term:`Promise` that resolves to an ``Array`` of the
results of the functions registered for that hook (the order of which is
undefined).

Hook functions may return a value or a :term:`Promise`. The latter is sometimes
useful for delaying actions. For example, you may wish to return a
:term:`Promise` from the ``beforeAnnotationCreated`` hook when an asynchronous
task must complete before the annotation data can be saved.


.. function:: configure(registry)
Expand Down

0 comments on commit ef76e8d

Please sign in to comment.