MCPcopy Create free account
hub / github.com/TanStack/hotkeys / injectLazyStore

Function injectLazyStore

packages/angular-hotkeys/src/injectHotkeyRecorder.ts:112–128  ·  view source on GitHub ↗
(
  storeSignal: Signal<Atom<TState> | ReadonlyAtom<TState>>,
  selector: (state: NoInfer<TState>) => TSelected,
)

Source from the content-addressed store, hash-verified

110}
111
112function injectLazyStore<TState, TSelected = NoInfer<TState>>(
113 storeSignal: Signal<Atom<TState> | ReadonlyAtom<TState>>,
114 selector: (state: NoInfer<TState>) => TSelected,
115): Signal<TSelected> {
116 const slice = linkedSignal(() => selector(storeSignal().get()))
117
118 effect((onCleanup) => {
119 const currentStore = storeSignal()
120 slice.set(selector(currentStore.get()))
121 const { unsubscribe } = currentStore.subscribe((s) => {
122 slice.set(selector(s))
123 })
124 onCleanup(() => unsubscribe())
125 })
126
127 return slice.asReadonly()
128}

Callers 1

injectHotkeyRecorderFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…