Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add activity.write and save to datastore before stop #63

Closed
wants to merge 1 commit into from

Conversation

manuq
Copy link
Contributor

@manuq manuq commented Jul 12, 2013

Activities that want to store something should override activity.write
. It is called before the activity stop.

Activities that want to store something should override activity.write
.  It is called before the activity stop.
@manuq
Copy link
Contributor Author

manuq commented Jul 12, 2013

Here is how GTD activity is using it:

https://github.com/manuq/gtd-activity/blob/master/js/activity.js#L17

@dnarvaez
Copy link
Contributor

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.

@manuq
Copy link
Contributor Author

manuq commented Jul 12, 2013

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?

@dnarvaez
Copy link
Contributor

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.

@manuq
Copy link
Contributor Author

manuq commented Jul 25, 2013

Yeah, I will try. I did this little diagram, with the datastore interactions marked. Maybe we can do it with JS events.
web-lifecycle

@dnarvaez
Copy link
Contributor

Looks perfect to me.

@manuq manuq closed this Jul 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants