solid
solid copied to clipboard
Should there be a version of useStore & useSignal which return a [accessor, setter] pair?
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