Skip to content

Event not firing when reactive variable is set #245

@dhirschfeld

Description

@dhirschfeld

I'm trying to create a solara=1.19.0 component in jupyterlab=4.0.5 with ipywidgets=8.1.0 (on Windows)

I have from_date = sol.use_reactive(cast(Optional[str], None)) which will be set to (a string repr of) a date.

I have a Select widget which uses this reactive variable and triggers a cb_from_date callback:

sol.Select(
    label="Effective Date",
    value=from_date,
    values=effective_dates,
    on_value=cb_from_date,
)

When I first set the value of the reactive variable to_date.value = effective_dates[0] everything works as intended - a cascade of callbacks/events trigger from other (reactive) variables being set 🎉

What I'm observing is that when I update the value to_date.value = effective_dates[0], the cascade of callbacks/events aren't being triggered if effective_dates[0] is the same as it was previously - i.e. the callback isn't being triggered if to_date.value == effective_dates[0]

The effective dates are being updated from a database, but it's very often that effective_dates[0] won't change. Even if effective_dates[0] hasn't changed, I still want all the callbacks/events to fire as other things have changed and I want the state of the app to be updated.

Does that make sense?

Is this behaviour intended, or a bug? If intended, is there some way to ensure the callback gets triggered whenever the reactive variable is set, irrespective of whether it is being set to the same value it has already?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions