I have a requirement: to open a new window in angular 6 and establish two way communication between the primary and secondary window.
I created a service WindowRef to open a new window/tab using angular "Window". I created an @ngrx/store system to manage state in the app. I am able to manage application state for any number of actions in the primary window, however when I open a new window and try accessing the state, it returns null.
If I can maintain state I can try and use ngStore to dispatch actions and try and establish two way communication channel between the primary and secondary opened window.
Can someone please suggest/ point me to a way to implement the above requirement?
ngrx/store
works in memory, meaning that if you refresh your page (or open a new tab) the current state in the Store will be lost.
If you want to communicate between both windows you can implement some sort of server side communication, e.g. firebase.
Another option without server would be to store the state/actions in your localStorage
and listen to changes in the localStorage
to update the state in a window.