This will cause the LiveState instance to be set on the window as todoLiveState. An element that wishes to connect to an existing LiveState instance uses the context property:
This will find an instance with the specified name (in any scope). This will be handled regardless of order, if the consuming instance is created first a queue of consumers will be created that will be resolved and attached when the providing instance is created.
This typescript class decorator will:
connectedCallback
method that sets aliveState
property and callsconnectElement
disconnectedCallback
method that callsdisconnect
on theliveState
instanceBoth will call inherited callbacks.
The decorator expects to passed an object with the following properties, all of which are optional:
connectElement
connectElement
connectElement
Context
As of 0.7.0, we now support sharing LiveState instances via a context. The way this works is that one element will provide an instance like so:
This will cause the LiveState instance to be set on the
window
astodoLiveState
. An element that wishes to connect to an existing LiveState instance uses the context property:This will find an instance with the specified name (in any scope). This will be handled regardless of order, if the consuming instance is created first a queue of consumers will be created that will be resolved and attached when the providing instance is created.