store.$patch is actually a $put? #2661
Unanswered
daniesy
asked this question in
Help and Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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