Can we share Ember objects between tabbed instance


#1

Actual requirement is to open multiple tab instance of same application, but the data (ember objects) should be shared among instance. If we access the Ember instance via window object, observers are not registering and watched properly.

Anyone came across a solution?


#2

If by tab instance you mean browser tab… it’s not really trivial. The first solution that jumps to mind is always local storage, however that has restrictive size limits so you can only put so much data there. If you don’t need to put a ton of data into local storage then that might work well. There are a couple ember addons for using it. We did this at my last company and it worked pretty well but it required some annoying code for watching local storage and syncing changes across tabs.

Another thing you might look into is service workers. I’m not sure if it’s possible but you may be able to use them to sync data across tabs.

You can also sort of simulate this behavior if you use a backend that supports push via websockets or something (for example if you wrote an app on firebase and launched multiple instances as long as you write it properly the instances appear to behave the same way because data updates are pushed from the server).

Others may have more suggestions… but as far as just sharing the Ember Data store and/or browser tab memory… I’m not sure there’s a great way to do it. AFAIK browser tabs are meant to be sandboxed so you’re kinda fighting the design of the web browser itself here.


#3

Thanks dknutsen. Your reply summarized my thoughts. I meant the browser tab actually. So the only solution I got to know is to sync data between tabs. Using service workers or local storage.

I will look for more options. Thanks for the comment.


#4

I’ve used FeathersJs with GREAT success in more than four different projects, my latest being a real time chat mini app add-on for a legacy non-ember app that is often ran in multiple teams. Feathers works great as a backend to ember data, and syncs all clients in real time, both local tabs and remote computers. Feel free to ping me with questions