Skip to content

VueX store loses reactivity if shared using window on page with multiple Vue bundles #2181

@stam

Description

@stam

Version

3.4.0

Reproduction link

https://github.com/stam/multiple-vue-apps

Steps to reproduce

Clone the mentioned repo
npm i
npm run serve
open ./index.html
Click on the count++ buttons

What is expected?

I expect both counters to update and reactivity to be intact

What is actually happening?

Only one counter updates, as the Vuex store in the other app is not reactive


We have 2 vue bundles on the same page. They share their VueX store using window.globalStore, but when you press count++ only one app is updated.

The obvious fix would be to just use 1 vue bundle. However this doesn't work in my company's usecase: We are gradually migrating from a legacy server side rendered application to a SPA. Small parts of the application are being converted to Vue, where the legacy application loads the specific Vue bundles on demand. However multiple Vue bundles can live on the same page, and we want to share some state as we don't want to duplicate API calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions