W3C home > Mailing lists > Public > public-device-apis@w3.org > October 2013

[discovery-api] NSD and promises, questions

From: Jean-Claude Dufourd <jean-claude.dufourd@telecom-paristech.fr>
Date: Tue, 29 Oct 2013 15:30:13 +0100
Message-ID: <526FC675.1070503@telecom-paristech.fr>
To: Device APIs Working Group <public-device-apis@w3.org>
Dear all,

The NSD draft has been updated to use promises.
In the process of implementing that version, I am coming up with questions.

In the newest draft, getNetworkServices returns a promise.
Then the promise gets resolved.
Then if a new matching service is discovered and authorized, the 
onserviceavailable *callback* is used.
Then getNetworkServices is called again and returns a new promise, etc...

The first question is, if promises are supposed to avoid callbacks, why 
do we still have callbacks (onserviceavailable, onserviceunavailable) ?
Would it make sense to change onserviceavailable and 
onserviceunavailable to promises ?
Old usage:
     networkServices.onserviceavailable = function() {...};
would become:
     networkServices.onserviceavailable.then(function() {...});

The second question is, are promises-with-immutable-value-once-set the 
right model for NSD ?
It looks like a mutable promise would be better, but I understand from 
reading about promises that immutability is an important feature.
I am looking for a pattern that is easier to use on the author, as usual.

Best regards
JC
-- 
TÚlÚcom ParisTech <http://www.telecom-paristech.fr> 	*Jean-Claude
DUFOURD <http://jcdufourd.wp.mines-telecom.fr>*
Directeur d'Útudes
TÚl. : +33 1 45 81 77 33 	37-39 rue Dareau
75014 Paris, France

Site web <http://www.telecom-paristech.fr>Twitter
<https://twitter.com/TelecomPTech>Facebook
<https://www.facebook.com/TelecomParisTech>Google+
<https://plus.google.com/111525064771175271294>Blog
<http://jcdufourd.wp.mines-telecom.fr>
Received on Tuesday, 29 October 2013 14:30:47 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:33:01 UTC