dcorking / google-wave-resources

Automatically exported from code.google.com/p/google-wave-resources
0 stars 0 forks source link

Listen for state changes between gadget instances. #808

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
On waves where multiple instances of a gadget exist in a single wave, cross 
syncing state between gadget instances is difficult.

This is a mildly uncommon use case, but imaginable. Examples:

- A count down gadget where all instances of the count down in the wave need to 
synchronize.

- A drawing gadget where multiple 'panels' to draw on exist and one exists to 
show live summary of all panels which are open in thumbnail form.

- A todo gadget where a single wave has the todo list of each user along with 
associated priority of each task, and the gadget at the top of the wave has a 
master todo list from all of the other lists in the wave.

Currently this is solvable by:

- Gadget to Robot to Gadget communication.
(robots a bad at finding gadgets; introduces a robot purely for gadget to 
gadget comms)

- Gadgets share domain cookies and talk to each other that way
(doesn't handle real time sync nicely)

- Some kind of cross domain ajax sync
(introduces external server dependency, cross domain issues, real time sync 
still a problem)

Seems like it'd be a good solution to allow gadgets to register an interest in 
all state-update-events for instances of the same gadget. 

So, as a feature request to facilitate this sort of gadget: consider updating 
the gadget api to either allow gadget instances all to share a single state 
object, or add allow gadgets to register a separate event listener for updates 
from all gadgets and  sign the state update events with the id of the gadget 
which was updated.

Original issue reported on code.google.com by Douglas....@gmail.com on 23 Jun 2010 at 7:39

GoogleCodeExporter commented 9 years ago
There is another way to solve this problem:
Gadgets share localStorage and sessionStorage.
Each gadget instance can listen for the storage event and sync in real time. By 
prefixing the storage keys with the wave's id and the gadget's name, you could 
share state between gadget instances in a wave.

Original comment by celehner1 on 23 Jun 2010 at 5:36

GoogleCodeExporter commented 9 years ago
Why you're supposing that gadgets states will be changed only by one user? And 
all users will use HTML5 compatible browsers?

Original comment by fedor.in...@gmail.com on 23 Jun 2010 at 5:37

GoogleCodeExporter commented 9 years ago
If another user changes a gadget's state, your instance will get the state 
update, and then can notify your other instances via localStorage.

I'm pretty sure that all the browsers that support the Wave client support 
localStorage. As for the storage event the only one I'm not sure of is Firefox 
3.0, but that could be worked around with polling.

Original comment by celehner1 on 23 Jun 2010 at 6:18

GoogleCodeExporter commented 9 years ago
TBH I think the storage solution is the best idea for doing this so far. 

(yeah, it won't work on some browsers. *shrug* if wave even _ran_ for those 
browsers, it'd be so slow having the gadget not able to do real time sync 
wouldn't be an issue anyway).

Original comment by Douglas....@gmail.com on 24 Jun 2010 at 10:49

GoogleCodeExporter commented 9 years ago
Issue 807 has been merged into this issue.

Original comment by pamela.fox on 25 Jun 2010 at 1:04

GoogleCodeExporter commented 9 years ago

Original comment by pamela.fox on 25 Jun 2010 at 1:08