Constructor
new Loop()
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Methods
add(…var_args)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
var_args |
module:capsula.Loop |
<repeatable> |
loops to tie this parent loop to (an array of 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 loop to the given loops | |
var_args |
module:capsula.Loop |
<repeatable> |
loops to tie this parent loop to (an array of 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.Loop}
Creates a new loop for the capsule that represents the current context of execution (with the given name, if provided). Then, ties that newly created loop to this loop. Returns the newly created loop.
In other words, it discloses (publishes) this loop to the interface of the capsule that represents the current context of execution.
Assumes this loop 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 loop |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- module:capsula.Loop
getChildren() → {Array.<module:capsula.Loop>}
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- Array.<module:capsula.Loop>
getFQName(opt_sepopt) → {string}
Returns the fully qualified name of this loop, using the given separator if provided (if not, the :: is used by default).
The fully qualified name comprises the name of this loop, the name of the owner capsule of this loop, 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|module:capsula.Loop}
Returns the parent hook or loop this loop is tied to; or null if it is not tied to a parent hook or loop in the current context of execution.
Assumes this loop belongs to a part capsule of the capsule that represents the current context of execution. Otherwise it throws error.
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
isParentOf(…var_args) → {boolean}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
var_args |
module:capsula.Loop |
<repeatable> |
loops to check (an array of loops also accepted) |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
Returns:
- Type
- boolean
isPublic() → {boolean}
Returns whether this loop 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.Loop |
<repeatable> |
loops to untie this parent loop from (an array of loops also accepted) |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
renderInto(el)
Renders this loop (i.e. the DOM element this loop represents) into the given DOM element.
Parameters:
Name | Type | Description |
---|---|---|
el |
Element | the DOM element into which to render this loop |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
set(…var_args)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
var_args |
module:capsula.Loop |
<repeatable> |
loops to re-tie this parent loop to (an array of 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 loop |
- Source:
- See:
Throws:
- Type
- Error
setEventHandlers(onHook, offHook)
Sets onHook and offHook callbacks to be called each time the path of this loop is completed or broken.
onHook and offHook callbacks are always called with respect to a path that changed: when a path of this loop gets completed onHook function is called; when completed path of this loop is broken (fragmented) offHook is called.
The callbacks are called in the context of the owner capsule of this loop; reference "this" in callbacks points again to the owner of this loop.
Parameters:
Name | Type | Description |
---|---|---|
onHook |
function | callback function to be called each time a path of this loop gets completed |
offHook |
function | callback function to be called each time a complete path of this loop gets broken (fragmented) |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
setName(name)
Parameters:
Name | Type | Description |
---|---|---|
name |
string | a new name of this loop |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
setParent(parent)
Ties this loop to the given parent hook or loop in the current context of execution.
Assumes this loop belongs to a part capsule of the capsule that represents the current context of execution. Otherwise it throws error.
Parameters:
Name | Type | Description |
---|---|---|
parent |
module:capsula.Hook | module:capsula.Loop | a parent hook or loop to tie this loop to |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error
tie(var_args)
Parameters:
Name | Type | Description |
---|---|---|
var_args |
module:capsula.Hook | module:capsula.Loop | Array.<module:capsula.Loop> | hook, loop, or an array of loops to tie this loop to |
- Since:
- 0.1.0
- Source:
Throws:
- Type
- Error