Skip to content

model.on_some_change subtly breaks sometimes #943

Open
@jasongrout

Description

@jasongrout

The WidgetModel.on_some_change uses this.hasChanged, but if a previous change handler has called this.touch() or has saved a value (or maybe even just set a value??), the changed dictionary is wiped out, and on_some_change then does not fire.

We see this in bqplot, in the last few cells of the https://github.com/bloomberg/bqplot/blob/e3501c367af3f91559d702896ec49ba73189a614/examples/Advanced%20Plotting/Axis%20Properties.ipynb demo. If the cells changing the orientation of the color axis, sometimes the axis does not update. It turns out that there is a validation change handler (https://github.com/bloomberg/bqplot/blob/e3501c367af3f91559d702896ec49ba73189a614/js/src/AxisModel.js#L56, for example) that runs and saves changes, which then wipes out the model's last changes.

I think a much simpler state change model is one where state changes only occur after the current processing is done (i.e., saving is an asynchronous command, much more like the CQRS system like React). Also, if we're going to have validation methods, we might as well use backbone's real validation methods, rather than making change handlers also to validation.

CC @SylvainCorlay @ssunkara1 @dmadeka.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions