Function usePublisher

  • Returns a function that publishes its passed argument into the specified node.

    Type Parameters

    • T

    Parameters

    Returns (value: T) => void

    const signal$ = Signal<number>(true, (r) => {
    r.sub(signal$, (value) => console.log(`${value} was published in the signal`))
    })
    //...
    function MyComponent() {
    const pub = usePublisher(signal$);
    return <button onClick={() => pub(2)}>Push a value into the signal</button>
    }