Constructor
new Hook()
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Methods
add(…var_args)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
var_args |
module:capsula.Hook | module:capsula.Loop |
<repeatable> |
hooks and loops to tie this parent hook to (an array of hooks and loops also accepted) |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
addAt(at, …var_args)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
at |
number | the index to use when tying this parent hook to the given hooks and loops | |
var_args |
module:capsula.Hook | module:capsula.Loop |
<repeatable> |
hooks and loops to tie this parent hook to (an array of hooks and loops also accepted) |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
clear()
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
disclose(opt_nameopt) → {module:capsula.Hook}
Creates a new hook for the capsule that represents the current context of execution (with the given name, if provided). Then, ties that newly created hook to this hook. Returns the newly created hook.
In other words, it discloses (publishes) this hook to the interface of the capsule that represents the current context of execution.
Assumes this hook belongs to a part capsule of the capsule that represents the current context of execution. Otherwise it throws error.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
opt_name |
string |
<optional> |
the name of the newly created hook |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- module:capsula.Hook
getChildren() → {Array.<(module:capsula.Hook|module:capsula.Loop)>}
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- Array.<(module:capsula.Hook|module:capsula.Loop)>
getFQName(opt_sepopt) → {string}
Returns the fully qualified name of this hook, using the given separator if provided (if not, the :: is used by default).
The fully qualified name comprises the name of this hook, the name of the owner capsule of this hook, the name of its owner, and so on all the way up the capsule hierarchy.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
opt_sep |
string |
<optional> |
the separator to use to separate names in the returned fully qualified name |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- string
getId() → {number}
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- number
getName() → {string}
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- string
getOwner() → {module:capsula.Capsule}
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
getParent() → {module:capsula.Hook}
Returns the parent hook this hook is tied to; or null if it is not tied to a parent hook in the current context of execution.
Assumes this hook belongs to the capsule that represents the current context of execution. Otherwise it throws error.
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- module:capsula.Hook
isParentOf(…var_args) → {boolean}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
var_args |
module:capsula.Hook | module:capsula.Loop |
<repeatable> |
hooks and loops to check (an array of hooks and loops also accepted) |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- boolean
isPublic() → {boolean}
Returns whether this hook belongs to the capsule which is the current context of execution.
In other words, returns whether this.getOwner() === current context of execution.
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- boolean
remove(…var_args)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
var_args |
module:capsula.Hook | module:capsula.Loop |
<repeatable> |
hooks and loops to untie this parent hook from (an array of hooks and loops also accepted) |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
renderInto(el)
Renders this hook (i.e. the DOM elements it represents) into the given DOM element.
Parameters:
Name | Type | Description |
---|---|---|
el |
Element | the DOM element into which to render this hook |
- Since:
- 0.2.0
- Source:
Throws:
- Type
- Error
set(…var_args)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
var_args |
module:capsula.Hook | module:capsula.Loop |
<repeatable> |
hooks and loops to re-tie this parent hook to (an array of hooks and loops also accepted) |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
setClass(cls)
Parameters:
Name | Type | Description |
---|---|---|
cls |
string | the class to set to this hook |
- Source:
- See:
Throws:
- Type
- Error
setEventHandlers(onHook, offHook)
Sets onHook and offHook callbacks to be called each time the path of this hook is completed or broken.
onHook and offHook callbacks are always called with respect to a path that changed: when a path of this hook gets completed onHook function is called; when completed path of this hook is broken (fragmented) offHook is called.
The callbacks are called in the context of the owner capsule of this hook; reference "this" in callbacks points again to the owner of this hook.
Parameters:
Name | Type | Description |
---|---|---|
onHook |
function | callback function to be called each time a path of this hook gets completed |
offHook |
function | callback function to be called each time a complete path of this hook gets broken (fragmented) |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
setName(name)
Parameters:
Name | Type | Description |
---|---|---|
name |
string | a new name of this hook |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
setParent(parent)
Ties this hook to the given parent hook in the current context of execution.
Assumes this hook belongs to the capsule that represents the current context of execution. Otherwise it throws error.
Parameters:
Name | Type | Description |
---|---|---|
parent |
module:capsula.Hook | a parent hook to tie this hook to |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
tie(…var_args)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
var_args |
module:capsula.Hook | module:capsula.Loop |
<repeatable> |
hooks and loops to tie this hook to (an array of hooks and loops also accepted) |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error