| Page 1 of 1 | [ 4 posts ] |
|
Hi,
So it seems that, pending ticket [ticket=2528298][/ticket], I have to set emitFacade on events that I want to bubble. What's the best way to do this for a class, or instance? So far I've found: Code: Y.augment(O, Y.EventTarget, null, null, { emitFacade: true, }); .. which hopefully will override anything Base pulled in, and for instances, my best guess was: Code: o._yuievt.config.defaults.emitFacade = true; which doesn't appear to have any effect. Thanks, Peter |
|
Your augment code is correct for setting up a class where all events will emit a facade by default. Base does this by default, so you could extend Base. I'm not sure why you would need to do that on an instance that was already created -- modifying the default value will not have an effect on events already published. You can explicitly (re)publish any given event to change the emitFacade config, however.
-Adam |
|
Thanks Adam, I'll go with the augment method.
|
|
Actually, can you help me figure this out? I've tried this:
Code: function Foo () { arguments.callee.superclass.constructor.apply(this, arguments); } Y.augment(Foo, Y.EventTarget, null, null, {emitFacade: true}); Y.extend(Foo, Y.Base); a = new Foo; a.on('test:fnord', function (e) { console.log(e.details[0]); }); b = new Foo; b.addTarget(a); a.fire('test:fnord', 'a'); b.fire('test:fnord', 'b'); which prints only 'a'. I've also tried swapping the order of the augment and extend statements, to no effect. The motivation for modifying an instance is that in a couple places I've made instances of Y.Base because I've wanted a singleton resource of reference for other components to keep track of shared state, somewhat in the same way as the Y object. Certain well-known attributes can be accessed through get(), and any component can subscribe to certain well-known–or arbitrary–events. The singleton object doesn't know ahead of time of all the events that might be passed through it, so it can't pre-publish them. I suppose other components could call publish on the object upon add(). Subclassing Base for this purpose seems heavy-weight, and kind of dumb in a prototypal language, but might be the simplest thing. |
| Page 1 of 1 | [ 4 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group