MisoAI / miso-client-js-sdk

Miso JavaScript SDK for websites
MIT License
9 stars 0 forks source link

UI: recover item bindings when necessary #98

Open simonpai opened 11 months ago

simonpai commented 11 months ago

When the DOM is refreshed without handling workflows, the bindings are gone and break the trackers. We can recover the bindings from scratch by matching elements with data-role="item" elements and data in the hub.

simonpai commented 11 months ago

For now, we are simply skipping bindings when the weak reference of value on item elements are not ready yet. The binding refresh are invoked twice because:

  1. Tracker refreshes on proxy element sync.
  2. Tracker refresh is called when view is done rendering again, which happens later because of RAF.

We are keeping the first route due to recommendation SSR tracking support, but this may be changed in the future.