Subscriptions with multiple topics will get ignored in certain conditions #18

dcneiner opened this Issue Jul 17, 2011 · 0 comments


None yet

1 participant


I ran into a situation where my subscriptions weren't being called on publish, and through some digging discovered it would happen in the following situation:

// This handler will always work when topic1 or topic2 are published
amplify.subscribe( "topic1 topic2", function () { ... });


// Only when topic1 is fired will this ever work, topic3 is ignored.
amplify.subscribe( "topic1 topic3", function () { ... }); 

If you start a multiple topic subscription with a topic that has already been subscribed once, the remaining topics are ignored. If you change up the test in core/test/unit.js, you can see the error:

test( "multiple subscriptions", function() {
    expect( 4 );

    amplify.subscribe( "sub-a-1 sub-a-2 sub-a-3", function() {
        ok( true );
    amplify.publish( "sub-a-1" );

    amplify.subscribe( "sub-b-1 sub-b-2", function() {
        ok( true );

    // All topics but the first one are ignored if the first
    // topic in the string has already been subscribed.
    amplify.subscribe( "sub-b-1 sub-b-3", function() {
        ok( true );

    amplify.publish( "sub-b-2" );
    amplify.publish( "sub-b-2" );
    amplify.publish( "sub-b-3" );
@dcneiner dcneiner added a commit that closed this issue Jul 19, 2011
@dcneiner dcneiner Core: Multiple subscriptions are no longer ignored if a previously su…
…bscribed message is encountered early in the topic list. Closes #18
@dcneiner dcneiner closed this in 0d2ed16 Jul 19, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment