Public Singleton StateWorker constructor. As this is a
Singleton constructor it is only invoked the first time this
StateWorker class is targeted by the new operator. Furthermore
this constructor returns, depending of the presence of the source
parameter, a proxyfied instance of this StateWorker class
instead of the actual this reference.
The initial ExtendableMessageEvent source.
This method should only be invoked by the StateHandler.
Protected Readonly driverInternal Store.Driver employed as backing data storage. This property contains an instance of either the IndexedDB or the SQLite3 class as abstract facade to either storage provider.
Protected Readonly effectsInternal Mapping of Store.Effect locates to their corresponding bound Effects.
Protected Readonly proxiesInternal WeakMapping of proxyfied references to this StateWorker to the Store.Effects namespace containing Effects bound to this StateWorker.
Protected Readonly remotesProtected Readonly statesInternal Mapping of Bus.Handles to WeakMapping of
Store.States designated by an object reference. This reference
either points to the global self reference, if a Store is
deployed to be non-transient or, if the opposite applies, to the
proxyfied instance of this StateWorker. Through this
distinction stores are associated to either a globally shared reference or
to a locally contained and transparent Proxy reference to this.
Protected Readonly storesInternal Mapping of deployed Store.Types to their corresponding Bus.Handles.
Static Private activatePrivate static activate method, called when this StateWorker is instantiated as ServiceWorker in a browser environment upon activation of the ServiceWorker.
The fired ExtendableEvent.
Static Private installPrivate static install method, called when this StateWorker is instantiated as ServiceWorker in a browser environment upon installation of the ServiceWorker.
The fired ExtendableEvent.
Static Private messagePrivate static message method, called when this StateWorker is instantiated as ServiceWorker in a browser environment upon the reception of messages from the controlling Window.
The fired ExtendableMessageEvent.
Public connect method which connects this StateWorker to a
BusWorker through the supplied socket.
A MessagePort to the BusWorker.
A Promise resolving upon socket connection.
This method should only be invoked by the StateHandler.
Public deploy method which deploys the supplied store under the
supplied handle. If the Store is deployed transiently, the
supplied state is used as initial Store.State. Otherwise, if a
previously persisted Store.State exists, it takes precedence over
the supplied state. Furthermore, when the supplied Store.Type is
already deployed and matches the currently deployed source code, no
action is taken. If the store's sources mismatch, a TypeError is
thrown.
The extending Store InstanceType.
A Promise resolving upon Store deployment.
A TypeError when the supplied store mismatches.
This method should only be invoked by the StateHandler.
Public deprecate method. When the returned Promise resolves,
the deployed Store referenced by the supplied handle is
guaranteed to be deprecated. Otherwise a ReferenceError is
thrown (and therefore the returned Promise rejected).
The Bus.Handle representing the Store.
A Promise resolving upon Store deprecation.
A ReferenceError when no Store could be handled.
This method should only be invoked by the StateHandler.
Public dispatch method. Invoking this method while supplying a handle
and a appropriate action will apply the supplied Store.Action
against the Store deployed under the supplied handle. The
returned Promise resolves to the resulting new Store.State
of the Store after the supplied Store.Action was
dispatched against it.
The extending Store InstanceType.
The Bus.Handle representing the Store.
A type-guarded Store.Action to dispatch.
A Promise resolving to the resulting Store.State.
A ReferenceError when no Store could be handled.
This method should only be invoked by the StateHandler.
Public implant method which implants the supplied effect under
the supplied locate to the global sgrud.state.effects namespace.
When the supplied Effect is already implanted and matches the
currently implanted source code, no action is taken. If the effect's
sources mismatch, a TypeError is thrown.
The Store.Effect locate type.
A Promise resolving upon Store implantation.
A TypeError when the supplied effect mismatches.
This method should only be invoked by the StateHandler.
Public invalidate method. When the returned Promise resolves,
the implanted Effect referenced by the supplied locale is
guaranteed to be invalidated. Otherwise a ReferenceError is
thrown (and therefore the returned Promise rejected).
The Store.Effect locate type.
A Promise resolving upon Effect invalidation.
A ReferenceError when no Effect could be located.
This method should only be invoked by the StateHandler.
Private proxyPrivate proxy method wrapping this StateWorker instance in a
Proxy. The resulting Proxy is used to provide distinct
this references for each of the connected remotes and
intercepts dispatch invocations to provide the globally available
sgrud.state.effects namespace.
The initial ExtendableMessageEvent source.
A Proxy wrapping the StateWorker.
Generated using TypeDoc
The StateWorker is a background Thread which is instantiated by the StateHandler to handle the deployment of Stores and dispatching Store.Actions against them. The same goes for Effects, whose implantation the StateWorker handles.
Decorator
Singleton
See
StateHandler