-
Notifications
You must be signed in to change notification settings - Fork 0
Event handling
Instances of TagTrain are event emitters.
-
add-tag: Triggered when a tag is successfully added by any means, e.g. addTag. Argument: the string value of the added tag. -
reject-tag: Triggered when an attempt to add a tag failed, either by the user or by through the API. See addTag. Argument: the string value of the rejected tag. -
remove-tag: Triggered when a tag is removed by the user. Argument: the string value of the removed tag. -
remove-all: Triggered when all of the tags have been removed at once, via the removeAll instance method. Argument: an array of the string values of the removed tags. -
change: Triggered when the tags array changes. To get an array of the new tags, call getTags.
These are instance methods of TagTrain used to manage event handlers. They can be chained.
Assume tagTrain is an instance of TagTrain created in the manner described here.
tagTrain.on(String event, Function callback) -> TagTrain
Registers callback to be called when event is triggered. Returns a reference to tagTrain.
tagTrain.off(String event, Function callback) -> TagTrain
De-registers callback from being called when event is triggered. Returns a reference to tagTrain.
tagTrain.trigger(String event, ...data) -> TagTrain
Invokes all event handlers registered for event with tagTrain as the this value and data as arguments in the order than the handlers were added (see on). data is not passed as an array, but rather spread into arguments. Returns a reference to tagTrain.