Show:

Class: Base

uijet. Base

Base

new uijet.Base()

uijet.js, line 486

Base class for components. Defines events and signals APIs plus some OO extensions.

Methods

private_parseHandler(handler){function}

uijet.js, line 780

Normalizes a handler into a function if it's a String.

If handler is a:

  1. Method of this instance -> use this method.
  2. A registered signal handler -> use this handler.
  3. Otherwise -> create a new function that publishes this string as an event.

  4. If handler ends with '+' then it will be invoked with the arguments sent to it as its parameters.

  5. If handler starts with a '-' then it will be published as global event with the <id>. prefix.
Name Type Description
handler string | function

a handler or a string representation of a handler.

Returns:
parsed handler.

private_setResource(){uijet.Base}

uijet.js, line 725

Assigns the resource to this.resource.

Related options:

  • resource: a name of a registered resource or an object to use as a resource.
  • resource_name: a key to use when referencing the model's attributes form the context object. Defaults to the resource option if it's a string, otherwise to '<this.id>_data'.

holdSignal(topic){uijet.Base}

uijet.js, line 637

Holds a signal's handler from being triggered.

Name Type Description
topic string

the name of the signal to hold.

listen(topic, handler){uijet.Base}

uijet.js, line 575

Registers a handler for the given type.

Name Type Description
topic string

the signal's type to register.

handler function

the signal's handler to register.

notify(once, topic, args){*}

uijet.js, line 614

Triggers a signal of the given type and returns the result of its call. If no handler was registered for that signal returns undefined. If the first argument is a Boolean it is used to determine whether to make sure this signal is triggered once during current lifecycle stage. {@see Base} does not define a _finally method that is used to clean up these "once" states.

Name Type Description
once boolean optional

optional true flag to make sure this signal is notified once per lifecycle stage.

topic string

the name of the signal to notify.

args * optional repeatable

arguments to hand over to the signal's handler.

Returns:
result of the triggered handler or undefined.

publish(topic, data){uijet.Base}

uijet.js, line 721

Triggers an event of given type topic. If data is supplied it is handed over to the handler as an argument. topic is always prefixed with this.id + '.'.

Name Type Description
topic string

the type of the event to trigger.

data * optional

argument to pass to the event's handler as data.

register(){uijet.Base}

uijet.js, line 531

Registers the widget into uijet's sandbox and sets the instance's resource.

note: It is recommended to call this._super() first thing when overriding this method, to make sure the widget is in the sandbox.

Related options:

  • resource: a name of a registered resource or an object to use as a resource.
  • resource_name: a key to use when referencing the model's attributes form the context object. Defaults to the resource option if it's a string, otherwise to '<this.id>_data'.

releaseSignal(topic){*}

uijet.js, line 662

Releases and triggers a held signal. The handler is invoked with the arguments it was provided with on previous calls to Base#notify with same topic.

Name Type Description
topic string

the signal to release and trigger.

Returns:
result of signal handler's call.

subscribe(topic, handler){uijet.Base}

uijet.js, line 685

Registers the given handler under the given type topic. If handler is a Function it is bound to this instance as its context. If handler is a String it is used to find a method of same name to use as handler. If no method was found then a signal with same type's handler is used. If handler is a String and ends with a '+' then the arguments supplied to this handler will be passed to that method/signal handler.

Name Type Description
topic string

the type of the handler to register.

handler function | string

the handler to register or a name of a method of this instance or a signal's handler to use as handler.

unlisten(topic){uijet.Base}

uijet.js, line 588

Removes a handler of the given type. If no topic is given then removes all handlers.

Name Type Description
topic string optional

the signal's type to remove.

unregister(){uijet.Base}

uijet.js, line 555

Unregisters the widget from uijet's sandbox.

unsubscribe(topic, handler){uijet.Base}

uijet.js, line 702

Removes a handler from the registered events. If handler is not supplied then the handler that is currently registered for the given topic is used.

Name Type Description
topic string

the event type to remove from registry.

handler function optional

the handler to remove from the registry.