LiteMap

ol-ishare/state. LiteMap

State tracker for LiteMap instances

Constructor

new LiteMap(stores, options)

See:
Parameters:
Name Type Description
stores Array.<module:ol-ishare/store~Store>

See stores parameter in base class documentation

options Object

See options parameter in base class documentation

Extends

Members

keys :Array.<String>

Overrides:

All keys in the state

Type:

name :String

Overrides:

The optional name specified at instanciation or class name

Type:

state :Object

Overrides:

State at the time accessed

Type:

defaults :Object

Overrides:

Default values for the state (if any)

Type:

defaultStore :module:ol-ishare/store~Store

Overrides:

The Store from which to fetch states by default

Type:
  • module:ol-ishare/store~Store

Methods

watch(lite)

Overrides:

Start tracking the changes made to the given LiteMap.

This works by listening to change events from the LiteMap's OpenLayers map view and layers.

Parameters:
Name Type Description
lite module:ol-ishare/litemap~LiteMap

LiteMap instance

stopWatching()

Overrides:

Stops tracking changes made to the currently watched LiteMap.

Removes event listeners created in watch().

apply(lite) → {Promise}

Overrides:

Apply the given state to an already created LiteMap

NOT CURRENTLY IMPLEMENTED, this is a bug

Parameters:
Name Type Description
lite module:ol-ishare/litemap~LiteMap

An instance of the application to which to apply the current state.

Returns:

Returns Promise that resolves to a list of keys that had values which couldn't be applied to the LiteMap.

Type
Promise

addStore(store, makeDefaultopt)

Overrides:

Adds a Store to those that a state instance will update

Parameters:
Name Type Attributes Default Description
store module:ol-ishare/store~Store

Store to add. If the store is already registered then this will reregister it (and potentially change whether it is the default).

makeDefault Boolean <optional>
false

Whether the store should be made the default

removeStore(store) → {Boolean}

Overrides:

Removes a Store from those that a state instance will update

Parameters:
Name Type Description
store module:ol-ishare/store~Store

Store to remove. If the store is the current default, then the next one in the list of stores will become the default. To make a specific store the use setDefaultStore.

Returns:

whether the supplied store was found in the list of stores.

Type
Boolean

setDefaultStore(store) → {Boolean}

Overrides:

Sets a registered store to the default. If not currently registered, nothing will happen.

Parameters:
Name Type Description
store module:ol-ishare/store~Store

The store to make default

Returns:

Whether the store was found and changed to the default

Type
Boolean

get(keys) → {Object}

Overrides:

Get the value(s) for the specified key(s)

Parameters:
Name Type Description
keys Array.<String>

Key or keys to get from state

Returns:

Values for each requested key

Type
Object

set(keyOrDict, valueopt)

Overrides:

Set the value(s) for the specified key(s).

Note that: (a) all values are deep-copied and checked for casting to JSON, and (b) updates to the state are throttled by the options.interval value.

Parameters:
Name Type Attributes Description
keyOrDict String | Object

Key of value to set in state, or key-value pairs.

value * <optional>

If keyOrDict is a string key, this is for the value to set for that key.

reset(keys)

Overrides:

Change the value associated with the keys to those specified in options.defaults. If not set, they will be undefined.

Parameters:
Name Type Description
keys String

Keys to reset

sendToStores() → {Promise}

Overrides:

Sends the current state to all registered stores.

Returns:

Resolves to the keys of values that were successfully stored.

Type
Promise

updateFromStore(storeopt) → {Promise}

Overrides:

Updates state with values from the default Store (or a specified alternative).

Parameters:
Name Type Attributes Description
store module:ol-ishare/store~Store <optional>

Non-default store to use.

Returns:

Promise that resolves to the current state after it has been updated from the store

Type
Promise

override(options) → {Object}

Overrides:

Combines state default values, the passed in options, and the current state

The actual method of combining the options may vary from class to class, but the base class method should be a reasonable default for applications with a single options object

Parameters:
Name Type Description
options Object

Object containing settings used to initialize an application but could be anything - completely appication dependent.

Returns:

Default implementation returns new options object. Sub-classes should return the same types of objects passed as arguments, but definitely return something which makes it possible to pass the updated options to the application in a few steps (ideally one).

Type
Object