Untitled

mail@pastecode.io avatar
unknown
javascript
a month ago
428 B
1
Indexable
Never
/**
 * 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;
}


Leave a Comment