Merge pull request #996 from marcelklehr/doc/hook-return-values
Document, how return values of hooks are handled.
This commit is contained in:
commit
f3abe6e970
|
@ -1,6 +1,6 @@
|
||||||
# API
|
|
||||||
@include embed_parameters
|
@include embed_parameters
|
||||||
@include http_api
|
@include http_api
|
||||||
|
@include hooks
|
||||||
@include hooks_client-side
|
@include hooks_client-side
|
||||||
@include hooks_server-side
|
@include hooks_server-side
|
||||||
@include editorInfo
|
@include editorInfo
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Hooks
|
||||||
|
All hooks are called with two arguments:
|
||||||
|
|
||||||
|
1. name - the name of the hook being called
|
||||||
|
2. context - an object with some relevant information about the context of the call
|
||||||
|
|
||||||
|
## Return values
|
||||||
|
A hook should always return a list or undefined. Returning undefined is equivalent to returning an empty list.
|
||||||
|
All the returned lists are appended to each other, so if the return values where `[1, 2]`, `undefined`, `[3, 4,]`, `undefined` and `[5]`, the value returned by callHook would be `[1, 2, 3, 4, 5]`.
|
||||||
|
|
||||||
|
This is, because it should never matter if you have one plugin or several plugins doing some work - a single plugin should be able to make callHook return the same value a set of plugins are able to return collectively. So, any plugin can return a list of values, of any length, not just one value.
|
|
@ -1,11 +1,6 @@
|
||||||
# Client-side hooks
|
# Client-side hooks
|
||||||
Most of these hooks are called during or in order to set up the formatting process.
|
Most of these hooks are called during or in order to set up the formatting process.
|
||||||
|
|
||||||
All hooks registered to these events are called with two arguments:
|
|
||||||
|
|
||||||
1. name - the name of the hook being called
|
|
||||||
2. context - an object with some relevant information about the context of the call
|
|
||||||
|
|
||||||
## documentReady
|
## documentReady
|
||||||
Called from: src/templates/pad.html
|
Called from: src/templates/pad.html
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
# Server-side hooks
|
# Server-side hooks
|
||||||
These hooks are called on server-side.
|
These hooks are called on server-side.
|
||||||
|
|
||||||
All hooks registered to these events are called with two arguments:
|
|
||||||
|
|
||||||
1. name - the name of the hook being called
|
|
||||||
2. context - an object with some relevant information about the context of the call
|
|
||||||
|
|
||||||
## loadSettings
|
## loadSettings
|
||||||
Called from: src/node/server.js
|
Called from: src/node/server.js
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue