Closed manuq closed 11 years ago
Here is how GTD activity is using it:
https://github.com/manuq/gtd-activity/blob/master/js/activity.js#L17
I wonder if it would be better to have Activity provide only a "session" API, for example start/activate/deactivate/stop and then let activities decide when they want to save to datastore. It feels more flexible to me.
Yeah I don't like very much the implementation. In GTK is easier because activities are made as classes, which inherit Activity. And as an activity developer you override the methods read() and write().
In the Sugar way, data storage is transparent to the user. There is no 'save' button. GTK activities persist data when they go to the background or when they stop. They call write(). I think we should aim to do the same approach in web activities. But I don't like my current implementation.
So a session API might be better. How would you implement it?
As discussed in irc, I think we can do it in apisocket. We are already associating socket to activity, we just need to watch activity lifecycle and forward notifications to js.
Yeah, I will try. I did this little diagram, with the datastore interactions marked. Maybe we can do it with JS events.
Looks perfect to me.
Activities that want to store something should override activity.write . It is called before the activity stop.