Reference Source
public class | source

Plugin

Base class for Viewer plugin classes.

Constructor Summary

Public Constructor
public

constructor(id: string, viewer: Viewer, cfg: Object)

Creates this Plugin and installs it into the given Viewer.

Member Summary

Public Members
public

ID for this Plugin, unique within its Viewer.

public

The Viewer that contains this Plugin.

Method Summary

Public Methods
public

Destroys this Plugin and removes it from its Viewer.

public

error(msg: String)

Logs an error message to the JavaScript developer console, prefixed with the ID of this Plugin.

public

fire(event: String, value: Object, forget: Boolean)

Fires an event on this Plugin.

public

Returns true if there are any subscribers to the given event on this Plugin.

public

log(msg: String)

Logs a message to the JavaScript developer console, prefixed with the ID of this Plugin.

public

off(subId: String)

Cancels an event subscription that was previously made with Plugin#on or Plugin#once.

public

on(event: String, callback: Function, scope: Object): String

Subscribes to an event on this Plugin.

public

once(event: String, callback: Function, scope: Object)

Subscribes to the next occurrence of the given event, then un-subscribes as soon as the event is subIdd.

public

scheduleTask(task: *)

Schedule a task to perform on the next browser interval

public

warn(msg: String)

Logs a warning message to the JavaScript developer console, prefixed with the ID of this Plugin.

Public Constructors

public constructor(id: string, viewer: Viewer, cfg: Object) source

Creates this Plugin and installs it into the given Viewer.

Params:

NameTypeAttributeDescription
id string

ID for this plugin, unique among all plugins in the viewer.

viewer Viewer

The viewer.

cfg Object
  • optional

Options

Public Members

public id: string source

ID for this Plugin, unique within its Viewer.

public viewer: Viewer source

The Viewer that contains this Plugin.

Public Methods

public destroy() source

Destroys this Plugin and removes it from its Viewer.

public error(msg: String) source

Logs an error message to the JavaScript developer console, prefixed with the ID of this Plugin.

Params:

NameTypeAttributeDescription
msg String

The error message

public fire(event: String, value: Object, forget: Boolean) source

Fires an event on this Plugin.

Notifies existing subscribers to the event, optionally retains the event to give to any subsequent notifications on the event as they are made.

Params:

NameTypeAttributeDescription
event String

The event type name

value Object

The event parameters

forget Boolean
  • optional
  • default: false

When true, does not retain for subsequent subscribers

public hasSubs(event: String): Boolean source

Returns true if there are any subscribers to the given event on this Plugin.

Params:

NameTypeAttributeDescription
event String

The event

Return:

Boolean

True if there are any subscribers to the given event on this Plugin.

public log(msg: String) source

Logs a message to the JavaScript developer console, prefixed with the ID of this Plugin.

Params:

NameTypeAttributeDescription
msg String

The error message

public off(subId: String) source

Cancels an event subscription that was previously made with Plugin#on or Plugin#once.

Params:

NameTypeAttributeDescription
subId String

Subscription ID

public on(event: String, callback: Function, scope: Object): String source

Subscribes to an event on this Plugin.

The callback is be called with this Plugin as scope.

Params:

NameTypeAttributeDescription
event String

The event

callback Function

Called fired on the event

scope Object
  • optional
  • default: this

Scope for the callback

Return:

String

Handle to the subscription, which may be used to unsubscribe with #off.

public once(event: String, callback: Function, scope: Object) source

Subscribes to the next occurrence of the given event, then un-subscribes as soon as the event is subIdd.

This is equivalent to calling Plugin#on, and then calling Plugin#off inside the callback function.

Params:

NameTypeAttributeDescription
event String

Data event to listen to

callback Function

Called when fresh data is available at the event

scope Object
  • optional
  • default: this

Scope for the callback

public scheduleTask(task: *) source

Schedule a task to perform on the next browser interval

Params:

NameTypeAttributeDescription
task *

public warn(msg: String) source

Logs a warning message to the JavaScript developer console, prefixed with the ID of this Plugin.

Params:

NameTypeAttributeDescription
msg String

The error message