Show:

jsPlumbUtil.EventGenerator Class

Provides event bind/fire functionality.

Methods

bind

(
  • event
  • listener
  • [insertAtStart=false]
)

Binds a listener to one or more events.

Parameters:

  • event String | String

    Name(s) of the event(s) to bind to. Note that if you provide multiple event names they all are bound with the same function.

  • listener Function

    Function to execute.

  • [insertAtStart=false] Boolean optional

    Whether or not to insert this listener at the start of the listener list, so it is fired before the other currently registered listeners.

cleanupListeners

()

Removes all listeners.

fire

(
  • event
  • value
  • originalEvent
)
private

Fires an update for the given event.

Parameters:

  • event String

    Event to fire

  • value Object

    Value to pass to the event listener(s).

  • originalEvent Event

    The original event from the browser

isSuspendEvents

() Boolean

Checks whether or not events are currently suspended.

Returns:

Boolean:

True if events are suspended, false otherwise.

jsPlumbUtil.replace

(
  • inObj
  • path
  • value
)

Replaces values inside some JS object according to a given path spec. A path spec is a string in dotted notation, with each component optionally declaring an array index. Some examples are:

foo.bar foo.baz[2] foo.qux[3].baz[3].shwee

The function fails gracefully if the path identifies a non-existent object.

Parameters:

  • inObj Object

    Object to perform replacements inside.

  • path String

    Path to use for replacements

  • value Object

    Value to set.

setSuspendEvents

(
  • val
)

Sets whether or not events are suspended.

Parameters:

  • val Boolean

    Whether or not to suspend events.

unbind

(
  • [eventOrListener]
  • [listener]
)

Clears either all listeners, or listeners for some specific event, or just some listener. You can call this method with zero, one or two arguments: with zero arguments, all listeners are cleared. With one argument that is a string, all listeners for the specified event type are cleared. With one argument that is a function, it is removed from the appropriate event list. With two arguments, the first is an event type, and the second is a function to be unbound. In fact this is perhaps unnecessary given that you can unbind a function just by passing it.

Parameters:

  • [eventOrListener] String | Function optional

    If a string, constrains the clear to just listeners for the event identified by the string. If a Function, unbinds this function wherever it may have been bound.

  • [listener] Function optional

    If provided, removes just this listener for the given event.