States
Base states functionality for State and racks
Table of Contents
- Methods
- Properties
- Events
Methods
close
()
Closes the end point and stops listening for events.
This method no longer needs to be explicitly called as end points are now automatically closed when the last event listener is removed.
loadFirstState
-
delayed=false
Load the first state
Parameters:
-
[delayed=false]
Boolean optionalWhether to perform a delayed or immediate load
loadLastState
-
delayed=false
Load the last state
Parameters:
-
[delayed=false]
Boolean optionalWhether to perform a delayed or immediate load
loadNextState
-
direction
-
delayed=false
-
wrap=false
Load the next or previous state
Parameters:
-
direction
NumberDirection to move (1 = next, -1 = previous)
-
[delayed=false]
Boolean optionalWhether to perform a delayed or immediate load
-
[wrap=false]
Boolean optionalWhether to wrap around at the start/end
loadStateByIndex
-
index
-
delayed=false
Load the State at a given index position
Parameters:
-
index
NumberThe zero based index of the State to load
-
[delayed=false]
Boolean optionalWhether to perform a delayed or immediate load
loadStateByProgram
-
index
-
delayed=false
Load the State with a given program number
Parameters:
-
index
NumberThe zero based program number of the State to load
-
[delayed=false]
Boolean optionalWhether to perform a delayed or immediate load
open
()
Opens this end point and starts listening for events.
This method no longer needs to be explicitly called as end points are now automatically opened when the first event listener is attached.
Use this method to keep the end point open even when no event listeners are attached.
untilOpen
()
Promise
Returns a promise that will be resolved when this end point is opened
Returns:
Example:
let C = new CantabileApi();
C.application.open();
await C.application.untilOpen();
Properties
Events
changed
Fired when anything about the contents of state list changes
currentStateChanged
Fired when the current state changes
itemAdded
Fired after a new state has been added
Event Payload:
-
index
NumberThe zero based index of the newly added item
itemChanged
Fired when something about an state has changed
Event Payload:
-
index
NumberThe zero based index of the item that changed
itemMoved
Fired when an item has been moved
Event Payload:
-
from
NumberThe zero based index of the item before being moved
-
to
NumberThe zero based index of the item's new position
itemRemoved
Fired after a state has been removed
Event Payload:
-
index
NumberThe zero based index of the removed item
nameChanged
Fired when the name of the containing song or rack changes
reload
Fired when the entire set of states has changed (eg: after a sort operation, or loading a new song/rack)