Search
Loading...
Skip to content

Function: _makeSource

function _makeSource<T>(): _Source<T>;

Creates a simple event source that can emit values to subscribed listeners.

This is the most basic building block - a pub/sub pattern without state management.

Type Parameters#

Type Parameter
T

Returns#

_Source<T>

A source function with an emit method

Example#

const onResize = makeSource<{ width: number; height: number }>();
// Subscribe
const unsubscribe = onResize((size) => {
console.log('New size:', size);
});
// Emit
onResize.emit({ width: 800, height: 600 });
// Cleanup
unsubscribe();