Answered possible RxJs AsyncSubject bug

  • 27 พฤศจิกายน 2554 7:36
     
      มีโค้ด

    Hi,

    Using the current stable release, it looks like if you subscribe to an AsyncSubject while it is processing an onNext call, then the subscription never gets its value.

     

    Here's a qunit test showing the problem.  the "second subscription" never gets a value.  The 1st, 3rd, and 4th subscriptions do get a value.

     

        QUnit.asyncTest("AsyncSubject bug", 4, function () {
            var a = new Rx.AsyncSubject(),
                valueReceived = new Rx.Subject(); // each subscription signals this when it gets its value so we can end the test
    
    
            // wait for 4 values to be received.
            valueReceived.Take(4).Timeout(1000).CatchErrorAndFailTest().FinallyStartQUnit().Subscribe();
    
            a.Subscribe(function (value) {
                QUnit.ok(true, "first subscription received value");
                valueReceived.OnNext(value);
    
                // subscribe again
                a.Subscribe(function (value) {
                    QUnit.ok(true, "second subscription received value");
                    valueReceived.OnNext(value);
                });
            });
    
            a.OnNext(1);
            a.OnCompleted();
    
            a.Subscribe(function (value) {
                QUnit.ok(true, "third subscription received value");
                valueReceived.OnNext(value);
    
                a.Subscribe(function (value) {
                    QUnit.ok(true, "fourth subscription received value");
                    valueReceived.OnNext(value);
                });
            });
        });
    
    

     


    This is the qunit output:

    Cdis.Rx.ExtensionsAsyncSubject bug (13, 4)Rerun

    1. first subscription received value (+0ms)
    2. third subscription received value (+0ms)
    3. fourth subscription received value (+0ms)
    4. Error: Timeout (+1006ms)

     

    Is this a bug or intended behaviour?


    • แก้ไขโดย bman654 27 พฤศจิกายน 2554 7:39
    •  

ตอบทั้งหมด

  • 20 มีนาคม 2555 3:39
     
     คำตอบ

    That is a bug and has been corrected in the version 1.0.10621.0 released back in December.

    Thanks,
    -- Matt

    • เสนอเป็นคำตอบโดย Matt Podwysocki 20 มีนาคม 2555 3:39
    • ทำเครื่องหมายเป็นคำตอบโดย bman654 20 มีนาคม 2555 5:10
    •  
  • 20 มีนาคม 2555 5:10
     
     
    Ahh I missed the new release.  Thanks