redux-state-sync | lightweight middleware to sync your redux state | State Container library
kandi X-RAY | redux-state-sync Summary
kandi X-RAY | redux-state-sync Summary
A lightweight middleware to sync your redux state across browser tabs
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- An event listener .
- Register new SWF service
- Checks if a service is reloaded
- Check if action is allowed
- Unregister the service worker
- Generate a unique action
- step 4 4 4
- Syncs if action is synced .
- Generates a unique id
- return true if event is async
redux-state-sync Key Features
redux-state-sync Examples and Code Snippets
Community Discussions
Trending Discussions on redux-state-sync
QUESTION
I have angular app supporting multiple browser tabs that has 2 bindings other using angular-redux @select and other one {{ property }}. The app works as expected. However I can break the bindings by configuring my angular store using redux-state-sync middleware to use broadcast-channel instead of localstorage. So replacing a row with a commented row below it in app.component.ts breaks the bindings in 2nd browser window. This seems really strange and I have no idea how to find out why both bindings break from seemingly unrelated change.
EDIT: Refering to yurzui's answer: the state is synced across the tabs also with broadcast-channel option. Only the bindings don't work anymore. This can be verified in console output in different browser tabs when button is pressed.
app.component.html
...ANSWER
Answered 2019-May-22 at 12:27When you use localstorage channel your application is subscribed to browser storage event. And once your application changes the value in one tab it updates locastorage which fires storage
event in other tab so it's updated.
With default redux_state_sync
channel you don't have such connection between tabs but channel now uses BroadcastChannel which is not patched by zonejs so you always get message not in angular zone.
What can you do?
Manually run code inside Angular zone on subscribe:
QUESTION
I have existing code where I have configured the store in AppModule constructor:
...ANSWER
Answered 2019-May-16 at 05:50Unfortunately I didn't get this to work properly on broadcast-channel (see Why redux @select does not work even though the state is changed when using redux-state-sync?) so here it is with localstorage.
app.module.ts
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install redux-state-sync
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page