-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Force display_message to be processed in order #7801
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.