<div dir="ltr">+1 to Subscribing read and write functions in activity.setup()<br><br><div>I'll chip in as well once I'm done with the Object Chooser api part.  <br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On 16 August 2013 19:34, Walter Bender <span dir="ltr"><<a href="mailto:walter.bender@gmail.com" target="_blank">walter.bender@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Fri, Aug 16, 2013 at 8:01 AM, Manuel Quiñones <<a href="mailto:manuq@laptop.org">manuq@laptop.org</a>> wrote:<br>
> This is one of the most important APIs we will have, so I would<br>
> like to open discussion on it.<br>
><br>
> In GTK activities, the activity developer subclass Activity, and<br>
> override read() and write() methods.<br>
><br>
> In web activities, we don't have that kind of hierarchy.  Instead, the<br>
> activity developer imports 'activity/activity' module, and calls<br>
> activity.setup() .  Then she/he can use activity.getDatastoreObject()<br>
> to read and write.<br>
><br>
> In GTK activities, 'read' is called at startup and 'write' is called<br>
> when the activity goes to the background or when it stops.  Recently,<br>
> I added in sugar-web those notifications, with the intention to make<br>
> web activities behave like GTK ones.<br>
><br>
> I provided an initial patch and dnarvaez proposed another option:<br>
> <a href="https://github.com/sugarlabs/sugar-web/pull/74" target="_blank">https://github.com/sugarlabs/sugar-web/pull/74</a><br>
><br>
> So we can:<br>
><br>
> - Let web developers connect to the 'pause' and 'stop' notifications,<br>
>   and use the activity datastore object directly. Pro: is more<br>
>   flexible.  Con: more work in the activity side: error handling,<br>
>   datastore object handling.<br>
><br>
> - Subscribe 'read' and 'write' functions in activity.setup() .  They<br>
>   will be called as expected, like in GTK.  'read' will have a JSON<br>
>   string as argument.  'write' must return a JSON string.  Pro:<br>
>   simpler approach.  Con: less flexibility in the activity side.  A<br>
>   mockup can be found in this comment:<br>
>   <a href="https://github.com/manuq/sugar-web/commit/3c2420f59c9aa8df44d2c0d639fe37b4af63f9fb#commitcomment-3872770" target="_blank">https://github.com/manuq/sugar-web/commit/3c2420f59c9aa8df44d2c0d639fe37b4af63f9fb#commitcomment-3872770</a><br>

><br>
> Thoughts?  Any other ideas?<br>
<br>
</div></div>Re read/write for JS, I think the solution has been sufficiently<br>
flexible for our Python activities. While I appreciate the flexibility<br>
of Not sure of connecting to pause and stop notifications, is there a<br>
use case where this is necessary or advantageous? Plus we need read in<br>
both scenarios.<br>
<div class="im HOEnZb"><br>
><br>
><br>
> --<br>
> .. manuq ..<br>
> _______________________________________________<br>
> Sugar-devel mailing list<br>
> <a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
> <a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
<br>
<br>
<br>
</div><span class="HOEnZb"><font color="#888888">--<br>
Walter Bender<br>
Sugar Labs<br>
<a href="http://www.sugarlabs.org" target="_blank">http://www.sugarlabs.org</a><br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Sugar-devel mailing list<br>
<a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
<a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
</div></div></blockquote></div><br></div>