Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / react/src/public-api / useWritable

Function: useWritable() ​

useWritable<T>(source): WritableBinding<T>

Defined in: projects/libraries/streamix/react/src/lib/useWritable.ts:19

Binds a Streamix Writable to React as a [value, setValue] pair.

Reads stay synchronized through useIterable; writes go directly to the Streamix source, so React never owns or mirrors the state.

Type Parameters ​

T ​

T

Parameters ​

source ​

Writable<T>

Returns ​

WritableBinding<T>

Example ​

tsx
const [count, setCount] = useWritable(counter);
<button onClick={() => setCount(count + 1)}>{count}</button>

Released under the MIT License.