Hi Alive, I like the referred changes and would definitely support them. We also need as well a mechanism to retrieve a set of settings at the same time. So the read function could also accept an array of settings ids. That would be very convenient and would avoid to rely on Promise.all, that will be done by the API behind the scenes
best El 26/09/14 09:18, "Alive" <[email protected]> escribió: >Hi folks, > >During the cleanup work of gaia system app[1], I found that nearly every >module inside system app (and so many other apps), >is using a shared library called SettingsListener[2] to help it deal with >read/write/observe settings. This is nothing wrong, but actually I/we >need more. > >As I am a big fan to event listener interface and frequently use this >pattern: > >```js >var A = { > init: function() { > window.addEventListener('enabled', this); > window.addEventListener('locked', this); > } > handleEvent: function(evt) { > } >}; >A.init(); >``` >|addEventListener| is possible to adopt an object or a function in its >2nd argument, >but our mozSettings.addObserver can only adopt function..why? We have >this pattern in gecko code base![3] >If we could use the same or similar pattern for observing a settings >change it¹d be great! > >```js >var B = { > init: function() { > mozSettings.addObserver('lockscreen.enabled', this); > mozSettings.addObserver('lockscreen.locked', this); > }, > observe: function(topic, value) { > } >}; >B.init(); >``` > >Also currently mozSettings.createLock().get()/set() doesn¹t smell nice. A >promise is something developer wants. >It¹d be nice if we have read/write without creating a lock and maintain >on our own.[4] >```js >mozSettings.read(Œlockscreen.enabled¹).then(function(value) {}); >mozSettings.write({Œlockscreen.enabled¹: true}).then(function() {}); >``` > >What do you think? > > >Best regard, >‹ >[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1072757 >[2] >https://github.com/mozilla-b2g/gaia/blob/master/shared/js/settings_listene >r.js >[3] >http://mxr.mozilla.org/mozilla-central/source/b2g/chrome/content/shell.js# >944 >[4] >https://github.com/mozilla-b2g/gaia/blob/master/shared/js/settings_listene >r.js#L14-L29 >-- >Alive C. Kuo, Firefox OS, Senior Software Engineer at Mozilla Taiwan, >Taipei office. >_______________________________________________ >dev-webapi mailing list >[email protected] >https://lists.mozilla.org/listinfo/dev-webapi > ________________________________ Este mensaje y sus adjuntos se dirigen exclusivamente a su destinatario, puede contener información privilegiada o confidencial y es para uso exclusivo de la persona o entidad de destino. Si no es usted. el destinatario indicado, queda notificado de que la lectura, utilización, divulgación y/o copia sin autorización puede estar prohibida en virtud de la legislación vigente. Si ha recibido este mensaje por error, le rogamos que nos lo comunique inmediatamente por esta misma vía y proceda a su destrucción. The information contained in this transmission is privileged and confidential information intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this transmission in error, do not read it. Please immediately reply to the sender that you have received this communication in error and then delete it. Esta mensagem e seus anexos se dirigem exclusivamente ao seu destinatário, pode conter informação privilegiada ou confidencial e é para uso exclusivo da pessoa ou entidade de destino. Se não é vossa senhoria o destinatário indicado, fica notificado de que a leitura, utilização, divulgação e/ou cópia sem autorização pode estar proibida em virtude da legislação vigente. Se recebeu esta mensagem por erro, rogamos-lhe que nos o comunique imediatamente por esta mesma via e proceda a sua destruição _______________________________________________ dev-b2g mailing list [email protected] https://lists.mozilla.org/listinfo/dev-b2g
