[Sugar-devel] Datastore API for html activities

Manuel Quiñones manuq at laptop.org
Mon May 27 20:18:34 EDT 2013


2013/5/27 Manuel Quiñones <manuq at laptop.org>:
> 2013/5/27 Daniel Narvaez <dwnarvaez at gmail.com>:
>> On 27 May 2013 22:16, Daniel Narvaez <dwnarvaez at gmail.com> wrote:
>>>
>>> Save an object
>>>
>>> textObject = datastore.TextObject();
>>> textObject.setText("Hello");
>>> textObject.setMetadata({"title": "hello"});
>>> textObject.save(onWrote);
>>>
>>> Load an object
>>>
>>> textObject = datastore.TextObject();
>>> textObject.load(onGotText);
>>> textObject.getMetadata(onGotMetadata);
>>>
>>
>> Probably StringObject would be less ambiguous than TextObject.
>
> Great job!  I think TextObject and setText are better because denote a
> text file.
>
> Could it be possible to do the API with less callbacks?  Like:
>
> var text = textObject.load();
> var metadata = textObject.getMetadata();

Or if a callback is needed for the asyncronous call, could it be only
one?  Like:

textObject = datastore.TextObject();
textObject.load(onLoad);

function onLoad(textObj) {
    var text = textObj.getText();
    var metadata = textObj.getMetadata();
}

--
.. manuq ..


More information about the Sugar-devel mailing list