Enable storing the callback outputs in the persistence storage #3144
+101
−46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR:
TLDR:
This PR adds a callback's property
enable_persistence: bool
(by defaultFalse
). If it'sTrue
, callback output value will be written within the browser's persistence storage for itsdcc
components that haspersistence=True
set.For the following code (also posted in the Dash Plotly forum question that's linked above):
There are screen recordings of how it works from the
plotly/dash::dev
branch vs thepetar-qb/dash::feature/callback_enable_persistence
branch:How it works from the
plotly/dash::dev
(it works exactly the same from the feature branch too if the callbackenable_persistence
is not set or is set toFalse
):Screen.Recording.2025-01-30.at.11.07.24.mov
How it works from the
petar-qb/dash::feature/callback_enable_persistence
whenenable_persistence=True
is added :Screen.Recording.2025-01-30.at.11.09.25.mov
There's a sketch that represents the new behaviour:
The only difference between the current Dash behaviour and the feature branch is the third case in the sketch above. Specifically, when
enable_persistence=True
is set in the callback, the new value returned from the server will be stored persistently instead of being pruned.Contributor Checklist
I have broken down my PR scope into the following TODO tasks
enable_persistence
into the callback and clientside_callback signature (by default it'sFalse
).recordUiEdit
even on callback response.enable_persistence=True
,enable_persistence=True
,updateProps
that will callrecordUiEdit
only ifenable_persistence=True
recordUiEdit
can recursively record edits for children. This enables that setting the persistence from the callback output works even if nested object is returned.I have run the tests locally and they passed. (refer to testing section in contributing)
I have added tests, or extended existing tests, to cover any new features or bugs fixed in this PR
optionals
CHANGELOG.md