Untitled

 avatar
unknown
javascript
a year ago
428 B
8
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