npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@qyu/atom-state-react

v2.0.2

Published

Atomic Storage bindings for react

Readme

@qyu/atom-state-react

React bindings for @qyu/atom-state-core

Connect Store Context

const store = atomstore_new()

const root = <AtomStoreContext.Provider value={store}>
    <App />
</AtomStoreContext.Provider>

Implemented Hooks

useAtomStore

Returns Atom Store from closest context, throws if used outside of context

const App = () => {
    const store = useAtomStore()
}

useAtomDispatch

Returns dispatch function to run atom actions

const App = () => {
    const dispatch = useAtomDispatch()
}

useAtomValue

Get atomvalue from register or return value of selector

const atomvalue = atomvalue_new(() => 10)

const App = () => {
    const value = useAtomValue(atomvalue)

    return <div>
        {value}
    </div>
}

useAtomOutput

Same use useSignalOutput but used on atomvalue or atomselector

const atomstate = atomstate_new(() => 10)

const App = () => {
    const value = useAtomOutput(atomstate)

    return <div>
        {value}

        <button onClick={() => { store.reg(atomstate).input(store.reg(atomstate).output() + 10) }}>
            Increase value
        </button>
    </div>
}

useAtomConnect

Same as useSignalConnect but used on atomvalue or atomselector

const atomstate = atomstate_new(() => 10)

const App = () => {
    const connection = useAtomConnect(atomstate)

    return <div>
        {connection.value /* will be null at first render, then changed to number */}

        <button onClick={() => { store.reg(atomstate).input(store.reg(atomstate).output() + 10) }}>
            Increase value
        </button>
    </div>
}

useAtomState

Gets state from atom value in react's useState format

const atomstate = atomstate_new(() => 10)

const App = () => {
    const [state, state_set] = useAtomState(atomstate)

    return <button onClick={() => { state_set(state_old => state_old + 10) }}>
        {state}
    </button>
}

useAtomEffect

The same as useSignalEffect on @qyu/signal-core, but gets signal from provided selector or value

const atomstate = atomstate_new(() => 10)

const App = () => {
    useAtomEffect({
        target: atomstate,

        config: {
            emit: true 
        },

        listener: useCallback((target: OSignal<number>) => {
            console.log(target.output())
        }, [])
    })
}

useAtomChild

Get child of atomfamily

const atomfamily = atomfamily_new({
    key: (a: number, b: number) => `${a} ${b}`,
    get: (a: number, b: number) => atomvalue_new(() => ({ a, b }))
})

const App = () => {
    const child = useAtomChild({ atomfamily, params: [10, 15] })

    return <div>
        a: {child.a} b: {child.b}
    </div>
}

useAtomLoader

Request loader

const atomloader = atomloader_new_pure({
    throttler: throttler_new_immediate(),

    connect: () => {
        console.log("connected")

        return () => {
            console.log("disconnected")
        }
    }
})

const App = () => {
    // request is optional, true by default
    // if true - request loader, if not - does not
    useAtomLoader({
        atomloader,
        params: [],
        request: true 
    })
}

useAtomLoaderDynamic

Request loader inside of OSignal

const atomloader1 = atomloader_new_pure({
    throttler: throttler_new_immediate(),

    connect: () => {
        console.log("connected1")

        return () => {
            console.log("disconnected1")
        }
    }
})

const atomloader2 = atomloader_new_pure({
    throttler: throttler_new_immediate(),

    connect: () => {
        console.log("connected2")

        return () => {
            console.log("disconnected2")
        }
    }
})

const atomstate = atomstate_new(() => store.reg(atomloader1))

const App = () => {
    // request is optional, true by default
    // if true - request loader, if not - does not
    useAtomLoaderDynamic({
        atomloader: atomstate,
        params: [],
        request: true 
    })
}