Get live updates
Use this procedure to send new settings from a server to all open pages. The provider uses server-sent events (SSE).
Procedure
Make an endpoint on your server that sends an event stream.
Send a full configuration document in each message.
Import
eventSourceProviderfrommagic-cursor-wand/providers.Add the provider to the
providersoption:tsimport { createWand } from 'magic-cursor-wand'; import { eventSourceProvider } from 'magic-cursor-wand/providers'; createWand({ providers: [eventSourceProvider({ url: '/api/wand/stream', withCredentials: true })], });Send a new document from the server. Make sure that the page changes the effects.
Result
The first message gives the first document. Each new message replaces the slot of the provider. Thus a lost message does not cause a permanent difference.
The EventSource API cannot send headers. To send cookies for authentication, set withCredentials: true.
A change from a provider never starts a save. Thus the page does not send the change back to the server.