MCPcopy Create free account
hub / github.com/thetarnav/solid-devtools / createConsumers

Function createConsumers

packages/shared/src/primitives.ts:74–86  ·  view source on GitHub ↗
(
    initial: readonly Accessor<boolean>[] = [],
)

Source from the content-addressed store, hash-verified

72 * For **IOC**
73 */
74export function createConsumers(
75 initial: readonly Accessor<boolean>[] = [],
76): [needed: Accessor<boolean>, addConsumer: (consumer: Accessor<boolean>) => void] {
77 const [consumers, setConsumers] = createSignal([...initial], {name: 'consumers'})
78 const enabled = createMemo(() => consumers().some(consumer => consumer()))
79 return [
80 enabled,
81 consumer => {
82 setConsumers(p => [...p, consumer])
83 tryOnCleanup(() => setConsumers(p => p.filter(c => c !== consumer)))
84 },
85 ]
86}
87
88// TODO: contribute to @solid-primitives/memo
89

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…