Forums

Posting in these forums is disabled. These forums will be available for archive purposes. Please join the new forums at the links below:

  • yui-support - replaces the `YUI 3.x` and `YUI 3 Gallery` forums.
    We have created the following discussion categories within this group to aid discoverability for these most-used topics:
    • Charts for YUI Charts support.
    • DataTable for YUI DataTable support.
    • Gallery for YUI Gallery support, including support for published Gallery components as well as the Gallery process in general.
    • Tools for support of YUI’s suite of developer tools such as selleck, shifter, grover, yogi, etc.
    • Everything Else for questions that don’t fit one of the categories above, we’ve got you covered here.
  • yui-deprecated - replaces the `YUI 2.x` forum and the forums of other deprecated products (`YUI Doc`, `Builder`, `YUI PHP Loader`, etc.).
  [ 8 posts ]
New Topic | Post Reply | Print view
Previous topic | Next topic

Lee

  • Username: bigwebguy
  • Joined: Sat Jan 24, 2009 6:09 am
  • Posts: 7
  • Location: VA
  • Twitter: bigwebguy
  • GitHub: bwg
  • Gists: bwg
  • IRC: bwg
  • Offline
  • Profile
Tags:
  • async-queue
  • asyncqueue
  • bubble
  • plugin
  • queue

Addiing event target of asyncQueue not working

Post Posted: Sat Jan 22, 2011 1:27 pm
+0-
I have a plugin that uses an async-queue. I've added the plugin as an eventTarget for the async-queue but the events never bubble up to the plugin.

http://jsfiddle.net/bigwebguy/EUzPz/6/

you can see the plugin is a target of the queue, and the events are firing from the queue. they just never bubble up to the plugin.

Thanks,
Lee

Alberto Santini

YUI Contributor

  • Offline
  • Profile

Re: Addiing event target of asyncQueue not working

Post Posted: Sat Jan 22, 2011 3:57 pm
+0-
Hello Lee.

Maybe

b.queue.q.on(...) and so on.

Hope that helps,
Alberto

Lee

  • Username: bigwebguy
  • Joined: Sat Jan 24, 2009 6:09 am
  • Posts: 7
  • Location: VA
  • Twitter: bigwebguy
  • GitHub: bwg
  • Gists: bwg
  • IRC: bwg
  • Offline
  • Profile

Re: Addiing event target of asyncQueue not working

Post Posted: Sat Jan 22, 2011 4:12 pm
+0-
Yeah Alberto, there are a couple ways around it, such as re-firing the event from my plugin; but I'd like to know if there is something i'm doing incorrect or if there is a bug or some other reason its not working.

cheers.

Luke Smith

YUI Contributor

  • Username: lsmith
  • Joined: Thu Aug 28, 2008 7:50 am
  • Posts: 516
  • Location: Sunnyvale
  • Twitter: ls_n
  • GitHub: lsmith
  • Gists: lsmith
  • IRC: ls_n
  • YUI Developer
  • Offline
  • Profile
Tags:
  • asyncqueue
  • event
  • plugin
  • queue

Re: Addiing event target of asyncQueue not working

Post Posted: Sat Jan 22, 2011 9:00 pm
+0-
The events in AsyncQueue are not configured to bubble. You can have your plugin republish the events from the AQ passing bubbles:true like so:

Code:
var queue = new Y.AsyncQueue();
queue.publish({
    'execute' : { bubbles: true },
    'shift'   : { bubbles: true },
    'add'     : { bubbles: true },
    'promote' : { bubbles: true },
    'remove'  : { bubbles: true }
});

queue.addTarget(this);

this._queue = queue;


HTH

Lee

  • Username: bigwebguy
  • Joined: Sat Jan 24, 2009 6:09 am
  • Posts: 7
  • Location: VA
  • Twitter: bigwebguy
  • GitHub: bwg
  • Gists: bwg
  • IRC: bwg
  • Offline
  • Profile
Tags:
  • asyncqueue
  • docs
  • event
  • queue

Re: Addiing event target of asyncQueue not working

Post Posted: Sun Jan 23, 2011 4:46 am
+0-
Luke, I noticed that already with the complete event (its not published at all for some reason) and you can see in my jsfiddle, i am publishing complete without success
Code:
// async-queue for some reason doesnt publish the complete
// event so it wont bubble regardless, however publishing
// doesnt seem to make a difference
q.publish('complete', {
    bubbles: true,
    emitFacade: true
});


according to the eventTarget publish docs, bubble defauts to true as long as emitFacade is true:
Quote:
'bubbles': whether or not this event bubbles (true) Events can only bubble if emitFacade is true.

async queue publishes its events as:
Code:
this.publish({
    'execute' : { defaultFn : this._defExecFn,    emitFacade: true },
    'shift'   : { defaultFn : this._defShiftFn,   emitFacade: true },
    'add'     : { defaultFn : this._defAddFn,     emitFacade: true },
    'promote' : { defaultFn : this._defPromoteFn, emitFacade: true },
    'remove'  : { defaultFn : this._defRemoveFn,  emitFacade: true }
});


so unless the docs are incorrect, shouldn't those bubble already?

Lee

  • Username: bigwebguy
  • Joined: Sat Jan 24, 2009 6:09 am
  • Posts: 7
  • Location: VA
  • Twitter: bigwebguy
  • GitHub: bwg
  • Gists: bwg
  • IRC: bwg
  • Offline
  • Profile
Tags:
  • asyncqueue
  • event
  • node
  • plugin

Re: Addiing event target of asyncQueue not working

Post Posted: Mon Jan 24, 2011 7:56 am
+0-
it appears to be plugin related (or something that plugin uses) as it works fine when assigning a node instance as an eventTarget of async-queue

http://jsfiddle.net/bigwebguy/2sKZn/

i'll bug it.

Luke Smith

YUI Contributor

  • Username: lsmith
  • Joined: Thu Aug 28, 2008 7:50 am
  • Posts: 516
  • Location: Sunnyvale
  • Twitter: ls_n
  • GitHub: lsmith
  • Gists: lsmith
  • IRC: ls_n
  • YUI Developer
  • Offline
  • Profile
Tags:
  • asyncqueue
  • event
  • node
  • plugin

Re: Addiing event target of asyncQueue not working

Post Posted: Tue Jan 25, 2011 3:58 pm
+0-
Have you added a bug for this? I dug around and found the issue. AsyncQueue's construction chains to EventTarget's constructor for extension, but it does not pass a 'prefix' config to the EventTarget constructor. Bubbled events are only accessible via prefixed event names.

You can patch it with this:
Code:
Y.AsyncQueue.prototype._init = function () {
    Y.EventTarget.call(this, { prefix: 'queue', emitFacade: true });
    this._q = [];
    this.defaults = {};
    this._initEvents();
};


Note the prefix config 'queue' passed as to EventTarget.

Run that code before you instantiate any AsyncQueues, then to subscribe to the AsyncQueue's events from your plugin, use the prefixed event name, like so:
Code:
node.queue.on('queue:execute', callback);


The node.queue is because your fiddle plugin's NS is also 'queue', though the two are entirely unrelated.

This is absolutely a bug. If you filed it for a component other than AsyncQueue, please update it to be for AsyncQueue. I'll get the patch in the source and create a gallery module that patches it for use with 3.3.0.

Thanks for finding this!

Lee

  • Username: bigwebguy
  • Joined: Sat Jan 24, 2009 6:09 am
  • Posts: 7
  • Location: VA
  • Twitter: bigwebguy
  • GitHub: bwg
  • Gists: bwg
  • IRC: bwg
  • Offline
  • Profile
Tags:
  • asyncqueue
  • event
  • node
  • plugin
  • ticket
  • yui3

Re: Addiing event target of asyncQueue not working

Post Posted: Tue Jan 25, 2011 10:01 pm
+0-
yeah, the bug is here: http://yuilibrary.com/projects/yui3/ticket/2529864

I filed it against plugin because when i added node as a target of async-queue (no plugins), the events fired...so it seemed to be plugin specific. Maybe something else weird is going on there.

node as eventTarget of async-queue (events bubble)
http://jsfiddle.net/2sKZn/2/

thanks for looking at this.

Lee
  [ 8 posts ]
New Topic | Post Reply | Print view
Previous topic | Next topic
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