clientOnly()
function clientOnly\<T\>(options: ObservableOptions\<T\>): WritableObservable\<T\>;Defined in: src/lib/observable/clientOnly.ts:48
Create a client-only observable.
This observable exists only on the client and is not synchronized to the server. Other client-side modules can subscribe to value changes.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
options | ObservableOptions<T> | Configuration options |
Returns
A writable observable (client-only)
Example
// Client-side module
const uiState = clientOnly({
id: "my-module:uiState",
initialValue: { menuOpen: false, selectedTab: 0 },
});
// Subscribe to changes
uiState.subscribe((state, prev) => {
console.log("UI state changed:", state);
});
// Update value
uiState.update(s => ({ ...s, menuOpen: true }));