YousefED / SyncedStore

SyncedStore CRDT is an easy-to-use library for building live, collaborative applications that sync automatically.
https://syncedstore.org
MIT License
1.73k stars 52 forks source link

More concise Vue integration #109

Open texastoland opened 1 year ago

texastoland commented 1 year ago

I was just reading your Vue bindings! Maybe they could be simplified by manually triggering a ref without the reactive proxy 👀

export function enableVueBindings({ shallowRef, triggerRef }) { // Vue namespace
  customCreateAtom = (name, onBecomeObserved) => {
    onBecomeObserved?.()
    const ref = shallowRef()
    return {
      reportObserved: () => ref.value // read
      reportChanged: () => triggerRef(ref) // write
    };
  };
  customReaction = undefined // automatic in Vue
}

Totally untested 😅