Force display_message to be processed in order#7801
Conversation
Otherwise sometimes the display message will be processed before the update message.
629cbdd to
4035ee0
Compare
|
@jdfreder, @SylvainCorlay - review? |
|
I confirm that it solves my issue. This looks good. |
|
@jdfreder, @minrk - I think this bug fix could be a candidate for 3.0. The problem Sylvain was seeing was that if you created a widget in the same cell as displaying it, where the widget is dynamically loaded using requirejs, it often would not show up since the display message would beat the update message. |
|
Can you show an example that fails? |
|
You only need to use a custom model that is asynchronously loaded. For example, if you do In define(["widgets/js/widget"], function(Widget) {
"use strict";
var Bar= Widget.WidgetModel;
return {
Bar: Bar,
};
});Then we simple declare a Slider that uses this model: from IPython.html.widgets import IntSlider
from IPython.utils.traitlets import Unicode
from IPython.display import display
class BarSlider(IntSlider):
_model_name = Unicode('Bar', sync=True)
_model_module = Unicode('nbextensions/Foo/Bar', sync=True)
slider = BarSlider()
display(slider)In |
|
I haven't seen this problem myself with my ipython-flightwidgets repo. Is it frequent? @SylvainCorlay 's example code should work as-is. |
|
It is because you don't overload the model in your flight widget. This only
|
|
Oh I see, thanks. |
There was a problem hiding this comment.
state_change is probable a bad name for the promise since we use it more generically, but we can change it later.
Force display_message to be processed in order
Otherwise sometimes the display message will be processed before the update message.