Class: XOpatModuleSingleton

XOpatModuleSingleton

new XOpatModuleSingleton()

Singleton Module API, ready to run as an instance offering its features to all equally.
Source:

Extends

Members

POSTStore

Inherited From:
Source:

cache

Inherited From:
Source:

id

Inherited From:
Source:

uid

Inherited From:
Source:

xoContext

Inherited From:
Source:

Methods

addFilter()

Remove a specific event handler for a given event. See OpenSeadragon.EventSource::removeHandler Note: noop if registerAsEventSource() not called.
Inherited From:
Source:

addHandler()

Add an event handler for a given event. See OpenSeadragon.EventSource::addHandler Note: noop if registerAsEventSource() not called.
Inherited From:
Source:

addOnceHandler()

Add an event handler to be triggered only once (or X times). See OpenSeadragon.EventSource::addOnceHandler Note: noop if registerAsEventSource() not called.
Inherited From:
Source:

applyFilter()

Remove a specific event handler for a given event. See OpenSeadragon.EventSource::removeHandler Note: noop if registerAsEventSource() not called.
Inherited From:
Source:

error(e, notifyUser)

Raise error event. If the module did register as event source, it is fired on the item instance. Otherwise, it is fired on the VIEWER. todo better warn mechanism: -> simple way of module/plugin level context warns and errors (no feedback) -> advanced way of event warnings (feedback with E code)
Parameters:
Name Type Description
e
Properties
Name Type Description
code
message
error
notifyUser boolean fires error-user if true, error-system otherwise.
Inherited From:
Source:

(async) exportData() → {Promise.<any>}

Called to export data within 'export-data' event: automatically the post data store object (returned from initPostIO()) is given the output of this method: `await dataStore.set(options.exportKey || "", await this.exportData());` note: for multiple objects, you can either manually add custom keys to the `dataStore` reference upon the event 'export-data', or simply nest objects to fit a single output
Inherited From:
Source:
Returns:
Type
Promise.<any>

getHandler()

Get a function which iterates the list of all handlers registered for a given event, calling the handler for each. See OpenSeadragon.EventSource::getHandler Note: noop if registerAsEventSource() not called.
Inherited From:
Source:

getLocaleFile(locale) → {string}

Relative locale file location as locales/[locale].json. Override for custom locales file location.
Parameters:
Name Type Description
locale
Inherited From:
Source:
Returns:
relative file path
Type
string

(async) importData(data)

Called automatically within this.initPostIO if data available note: parseImportData return value decides if data is parsed data or passed as raw string
Parameters:
Name Type Description
data string | * data
Inherited From:
Source:

(async) initPostIO(optionsnullable) → {PostDataStore}

Initialize IO in the Element - enables use of export/import functions
Parameters:
Name Type Attributes Description
options XOpatStorage.StorageOptions <nullable>
where id value is ignored (overridden)
Properties
Name Type Attributes Default Description
exportKey string <optional>
<nullable>
"" optional export key for the globally exported data through exportData
Inherited From:
Source:
Returns:
data store reference, or false if import failed
Type
PostDataStore

integrateWithSingletonModule(moduleId, callback) → {boolean}

TODO: this does not wait once module is fully loaded!
Parameters:
Name Type Description
moduleId
callback
Inherited From:
Source:
Returns:
true if finished immediatelly, false if registered handler for the future possibility of the module being loaded
Type
boolean

numberOfHandlers()

Get the amount of handlers registered for a given event. See OpenSeadragon.EventSource::numberOfHandlers Note: noop if registerAsEventSource() not called.
Inherited From:
Source:

raiseAwaitEvent()

Trigger an event, optionally passing additional information. See OpenSeadragon.EventSource::raiseAwaitEvent. Awaits async handlers. Note: noop if registerAsEventSource() not called.
Inherited From:
Source:

raiseEvent()

Trigger an event, optionally passing additional information. See OpenSeadragon.EventSource::raiseEvent Note: noop if registerAsEventSource() not called.
Inherited From:
Source:

registerAsEventSource()

Set the element as event-source class. Re-uses EventSource API from OpenSeadragon.
Inherited From:
Source:

removeAllHandlers()

Remove all event handlers for a given event type. See OpenSeadragon.EventSource::removeAllHandlers Note: noop if registerAsEventSource() not called.
Inherited From:
Source:

removeFilter()

Remove a specific event handler for a given event. See OpenSeadragon.EventSource::removeHandler Note: noop if registerAsEventSource() not called.
Inherited From:
Source:

removeHandler()

Remove a specific event handler for a given event. See OpenSeadragon.EventSource::removeHandler Note: noop if registerAsEventSource() not called.
Inherited From:
Source:

t(key, options) → {*}

Translate the string in given element context
Parameters:
Name Type Description
key
options
Inherited From:
Source:
Returns:
Type
*

warn(e, notifyUser)

Raise warning event. If the module did register as event source, it is fired on the item instance. Otherwise, it is fired on the VIEWER. todo better warn mechanism: -> simple way of module/plugin level context warns and errors (no feedback) -> advanced way of event warnings (feedback with E code)
Parameters:
Name Type Description
e
Properties
Name Type Description
code
message
error
notifyUser boolean fires error-user if true, error-system otherwise.
Inherited From:
Source: