Talk:FUEL/0.1/Plan: Difference between revisions
No edit summary |
MarkFinkle (talk | contribs) No edit summary |
||
| Line 7: | Line 7: | ||
Good luck whatever you do! :-) | Good luck whatever you do! :-) | ||
[[User:GijsKruitbosch|GijsKruitbosch]] 23:38, 7 January 2007 (PST) | [[User:GijsKruitbosch|GijsKruitbosch]] 23:38, 7 January 2007 (PST) | ||
Regarding the services, I was thinking about a singleton pattern to cache the service after the first "get": | |||
<pre> | |||
// somewhere in the impl | |||
_os : null, | |||
Observer() : function() { | |||
if (_os == null) { | |||
// get the service from XPCOM | |||
} | |||
return _os; | |||
} | |||
</pre> | |||
Thanks for the feedback and ideas. Keep it coming! | |||
[[User:MarkFinkle|MarkFinkle]] 19:30, 9 January 2007 (PST) | |||
Revision as of 03:30, 10 January 2007
This seems interesting. A couple of points:
- Please do this in a Toolkit way, not in a Browser way. That is, I should be able to use the same simplified API in Thunderbird and/or any Toolkit (XULRunner) app. If this is not possible, extension devs will keep relying on existing (complicated) APIs because those do provide that compatibility.
- Have a look at some existing implementations. For example, ChatZilla/Venkman wrap preferences in a way much like what you describe, though there's more of a sacrifice made there to achieve ease of use by doing a less lightweight implementation. See http://lxr.mozilla.org/seamonkey/source/extensions/irc/js/lib/pref-manager.js
I'm also curious on how you would implement the Service thing. AFAICT, it would be impractical to keep all existing services around on an object - that is, it'd create a bunch of them the JS probably never needs. Implementing this using getters means you keep re-getting the service if you use the API like the example does. (ie, Service.Foo.stuff(bar); Service.Foo.unstuff(bar); ) This would probably be slow(er). Or so I'd presume, I haven't tested any of this.
Good luck whatever you do! :-) GijsKruitbosch 23:38, 7 January 2007 (PST)
Regarding the services, I was thinking about a singleton pattern to cache the service after the first "get":
// somewhere in the impl
_os : null,
Observer() : function() {
if (_os == null) {
// get the service from XPCOM
}
return _os;
}
Thanks for the feedback and ideas. Keep it coming! MarkFinkle 19:30, 9 January 2007 (PST)