import { Atom } from '@hullo/core';
const a = new Atom(/* initial state */ 0);
/* This will not get anywhere as a message
* but it'll be resent to any future subscriber
/* This subscription will log out to the console
* "A 1" immediately as that is a state of atom a */
const sub1 = a.subscribe({
next: v => { console.log('A', v); }
/* As there's no new subscription sending a message
* will trigger the same reaction
* as if `a` would be a channel.
* It will log "A 2" to the console */
/* Every new subscription to an atom
* Will receive last message as its first message.
* First subscription will not have this resent */
const sub2 = a.subscribe({
next: v => { console.log('B', v); }