n-riesco / ijavascript

IJavascript is a javascript kernel for the Jupyter notebook
Other
2.18k stars 187 forks source link

`$$.display()` updates dropped if cell execution completed #132

Closed n-riesco closed 6 years ago

n-riesco commented 6 years ago
$$.async();

var counter = $$.display("counter");

var n = 0;
counter.text(n++);

(function($$) {
    var stopCounter = (function() {
        var id = setInterval(function() {
            counter.text(n++);
        }, 1000);
        return function() {
            console.log("done");
            clearInterval(id);
            $$.done();
        }
    })();
    setTimeout(stopCounter, 10000);    
})($$);
n-riesco commented 6 years ago
var d1 =  $$.display("d1");
d1.text("1");
d1.text("2");

jupyter-notebook@4.2.3 final output is 1 jupyter-notebook@5.2.1 final output is 2

n-riesco commented 6 years ago
import os
from IPython.display import display
handle = display(0, display_id="counter")
for n in range(1, 10):
    os.system("sleep 1")
    handle.update(n)

ipython@5.1.0 thrown exception at handle.update(n) ipython@5.5.0 works as expected

n-riesco commented 6 years ago

https://github.com/n-riesco/nel/commit/0322589c978a664bdffecdfe0a1f2f698afc02fc addresses this issue (needs testing with jupyter-notebook@4.2.3 and jupyter-notebook@5.2.1).

n-riesco commented 6 years ago

https://github.com/n-riesco/nel/commit/0322589c978a664bdffecdfe0a1f2f698afc02fc tested on jupyter-notebook@5.2.1 using the example:

var counter = $$.display("counter");

var n = 0;
counter.text('' + n++);

(function($$) {
    var stopCounter = (function() {
        var id = setInterval(function() {
            counter.text('' + n++);
        }, 1000);
        return function() {
            console.log("done");
            clearInterval(id);
        }
    })();
    setTimeout(stopCounter, 10000);    
})($$);

Note the following gotchas:

n-riesco commented 6 years ago

Closed via NEL@0.5.8