Untitled
unknown
javascript
2 years ago
428 B
11
Indexable
/**
* Create a `Signal` that can be set or updated directly.
*/
export function createSignal<T>(initialValue: T): SignalGetter<T> {
const node: SignalNode<T> = Object.create(SIGNAL_NODE);
node.value = initialValue;
const getter = (() => {
producerAccessed(node);
return node.value;
}) as SignalGetter<T>;
(getter as any)[SIGNAL] = node;
return getter;
}
Editor is loading...
Leave a Comment