1.4 KiB
1.4 KiB
Update Signals
Demo
Apply random signals
Remove 2 random signals
<pre
class="border-2 border-accent bg-base-200 text-accent text-sm rounded-lg focus:ring-primary focus:border-primary block w-full p-2.5"
data-text="ctx.signals.JSON()"
data-on-signals-change="ctx.el.textContent = ctx.signals.JSON()"
>
Stuff in signals
</pre>
Explanation
This example demonstrates how to update the signals using an SSE event.
event: datastar-merge-signals,
data: signals { HYAAA4BK7IFQE: "2024-05-23T10:33:14.167189214-07:00", existingSignals: "this already exists"}
It will accept anything that is also accepted by the data-signals
attribute.
The removal event looks like this:
event: datastar-remove-signals,
data: paths 12768 existingSignals
Where the paths are .
delimited paths. For namespaced signals it might look like foo.bar.baz
. Using the Go helpers for example this looks like datastar.RemoveSignals(sse, keysToRemove...)