Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should there be a version of useStore & useSignal which return a [accessor, setter] pair? #7

Closed
btakita opened this issue Jan 1, 2022 · 2 comments

Comments

@btakita
Copy link
Contributor

btakita commented Jan 1, 2022

A [accessor, setter] pair would be useful for situations where solid components use both the accessor & setter. The atom.set() function could be setter but returning the [accessor, setter] pair is more idiomatic to Solidjs.

If we were to go this route, I propose the following types:

import type { Store } from 'solid-js/store'
import type { ReadableAtom, WritableAtom } from 'nanostores'
declare function useSignal<Value>(atom: WritableAtom<Value>):[()=>Value, (val:Value)=>void];
declare function useStore<Value>(atom: WritableAtom<Value>):[Store<Value>, (val:Value)=>void];
declare function useMemo<Value>(atom: ReadableAtom<Value>):()=>Value
@wobsoriano
Copy link
Collaborator

Will take a look at this. Thank you!

@wobsoriano
Copy link
Collaborator

Hey, I try to keep it as close as the React API so Im closing this one for now! ty ty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants