Well, I'm no message bus expert myself, but I see that the
checkSubscription method also calls for 3 parameters.  I wonder if the
comment about not including the function name and context in the method
means using null parameters instead of no parameter at all.

I don't know if that will make a difference, but the API docs usually
mark any optional parameter with a question mark "?".  These methods
don't have one shown, so I'm assuming they need to be included in the
method call one way or another.

Maybe someone else on the dev team can comment on the parameter
requirement issue with this particular API page.

Try that and let us know what happens.

  Gene

Try it by using 3 parameters to the method call rather than leaving them
completely out of the call, and see if that makes any difference.

 On Wed, 2009-06-10 at 23:44 +0200, Michael Helwig wrote:

> Hi Gene,
> 
> thanks, you are right, this at least works in the Playground. But I'm 
> still having problems in my actual code. My Application.js contains in 
> its members section:
> [CODE]
> 
> members : {
> 
> buildGUI : function () {
> 
>     if(hbtables.Application.messageBus.checkSubscription("CONFIG LOADED"));
>         
> qx.event.message.Bus.unsubscribe("CONFIG_LOADED",this.buildGUI,this);
> }
>     main : function () {
> 
>         hbtables.Application.messageBus = 
> qx.event.message.Bus.getInstance();
>         hbtables.Application.messageBus.subscribe("CONFIG LOADED", 
> this.buildGUI,this);
> }
> 
> }
> [/CODE]
> 
> This does not work. Checking the output of
> 
> [CODE]
> qx.dev.Debug.debugObject(hbtables.Application.messageBus.getSubscriptions());
> [/CODE]
> 
> later in the source shows that the function is still in the subscriber's 
> list - to be precise, I seem to get the whole document source in the 
> output of the debugObject above, which irritates me. Is this the correct 
> behavior?
> 
> Furthermore, the api documentation says about 
> qx.event.message.Bus.unsubscribe:
> 
> "unsubscribe a listening method _if_ you supply the callback function 
> and execution context, remove only this exact subscription _otherwise_ 
> remove all subscriptions"
> 
> This, I think, suggests that the second and third parameter are 
> optional. However, I'm not a native speaker.
> 
> Greets,
> Michael
> 
> Gene Amtower schrieb:
> > Michael,
> >
> > In my API docs, it lists 3 parameters for the Bus.subscribe and 
> > Bus.unsubscribe methods...
> >
> > *subscribe(String **message**, Function **subscriber**, Object 
> > **context**)*
> > *unsubscribe(String **message**, Function **subscriber**, Object 
> > **context**)*
> >
> > where the 3rd parameter is probably going to be "this" and appears to 
> > be required per the API docs. 
> >
> > When I used all three parameters in my Playground for both subscribe 
> > and unsubscribe, the error went away and both the subscibe and 
> > unsubscribe work correctly.  I moved the dispatch statement around to 
> > test the functionality, and it only worked when placed between the 
> > subscribe and unsubscribe calls.
> >
> >
> >> var messageBus = qx.event.message.Bus.getInstance();
> >>
> >> var message = new qx.event.message.Message("TEST");
> >>
> >>
> >>
> >> var myfunction = function() {
> >>
> >>    alert("Here I am");
> >>
> >> }
> >>
> >>
> >>
> >> messageBus.subscribe("TEST", myfunction, this);
> >>
> >> // messageBus.unsubscribe("TEST");
> >> messageBus.unsubscribe("TEST", myfunction, this);
> >>
> >> messageBus.dispatch(message);
> >>
> >
> > HTH,
> >
> >   Gene
> >
> >
> > On Wed, 2009-06-10 at 20:11 +0200, Michael Helwig wrote:
> >> Hi,
> >>
> >> how can I unsubscribe a function from a message bus 
> >> (qx.event.message.Bus)?
> >>
> >> Calling messageBus.unsubscribe("MESSAGE_TEXT") yields an error 
> >> ("sub[msgName] is null")
> >> Running the following in the Playground app also yields an error:
> >>
> >> [CODE]
> >> var messageBus = qx.event.message.Bus.getInstance();
> >> var message = new qx.event.message.Message("TEST");
> >>
> >> var myfunction = function() {
> >>    alert("Here I am");
> >> }
> >>
> >> messageBus.subscribe("TEST", myfunction);
> >> messageBus.unsubscribe("TEST");
> >> [/CODE]
> >>
> >> Error:
> >> playground.Application[p]: TypeError: k[l] is null
> >>
> >> The combinations
> >> [CODE]
> >> messageBus.unsubscribe("TEST", myfunction);
> >> //OR
> >> messageBus.unsubscribe(myfunction);
> >> [/CODE]
> >> have no effect, the function gets called if the message is dispatched 
> >> anyway.
> >>
> >> Am I doing something wrong or is this a bug?
> >>
> >> Greetings,
> >>
> >> Michael
> >>
> >>
> >> ------------------------------------------------------------------------------
> >> Crystal Reports - New Free Runtime and 30 Day Trial
> >> Check out the new simplified licensing option that enables unlimited
> >> royalty-free distribution of the report engine for externally facing 
> >> server and web deployment.
> >> http://p.sf.net/sfu/businessobjects
> >> _______________________________________________
> >> qooxdoo-devel mailing list
> >> qooxdoo-devel@lists.sourceforge.net 
> >> <mailto:qooxdoo-devel@lists.sourceforge.net>
> >> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
> >>     
> > ------------------------------------------------------------------------
> >
> > ------------------------------------------------------------------------------
> > Crystal Reports - New Free Runtime and 30 Day Trial
> > Check out the new simplified licensing option that enables unlimited
> > royalty-free distribution of the report engine for externally facing 
> > server and web deployment.
> > http://p.sf.net/sfu/businessobjects
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > qooxdoo-devel mailing list
> > qooxdoo-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
> >   
> 
> 
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables unlimited
> royalty-free distribution of the report engine for externally facing 
> server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> qooxdoo-devel mailing list
> qooxdoo-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to