New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dcneiner opened this Issue Jul 17, 2011 · 0 comments

Comments

Projects
None yet
1 participant
@dcneiner
Contributor

dcneiner commented Jul 17, 2011

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" );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment