You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This store is used in my main app and in an app loaded in an iFrame inside my main app. Each uses a different instance, so I wrote a plugin to synchronize the two stores by using the Post Message API and listening for store.$subscribe. Whenever one store state changes, it is sent to the other app. I use store.$patch to update the other store content with the value sent in the Post Message API.
However, whenever I use $patch, every component that uses the blocks gets re-rendered. Is there any way to update only the changed values in the blocks array? I don't want to replace the whole blocks array. Even stranger, every component seems to be unloaded first and then loaded again, making the UI flash for a few microseconds.
For example, if I add an image block and a header block (v-for with keys) and I change the header content in the iframe, the image will reload in the parent after the $patch runs in the parent store.
I tried listening for store.$onAction and recreating the action on the other store, but it doesn't cover the whole use cases.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Heya!
I build a store with an array of blocks, similar to this one
This store is used in my main app and in an app loaded in an iFrame inside my main app. Each uses a different instance, so I wrote a plugin to synchronize the two stores by using the Post Message API and listening for
store.$subscribe
. Whenever one store state changes, it is sent to the other app. I usestore.$patch
to update the other store content with the value sent in the Post Message API.Sending the store to the other component :
Parsing the message:
However, whenever I use
$patch,
every component that uses the blocks gets re-rendered. Is there any way to update only the changed values in the blocks array? I don't want to replace the whole blocks array. Even stranger, every component seems to be unloaded first and then loaded again, making the UI flash for a few microseconds.For example, if I add an image block and a header block (v-for with keys) and I change the header content in the iframe, the image will reload in the parent after the
$patch
runs in the parent store.I tried listening for
store.$onAction
and recreating the action on the other store, but it doesn't cover the whole use cases.Beta Was this translation helpful? Give feedback.
All reactions