[discovery-api] NSD and promises, questions

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