Skip to content

why use "with state" in a callback function invokes itself again? #617

Answered by jourdain
Roadelse asked this question in Q&A
Discussion options

You must be logged in to vote

The with state: is mainly mandatory when you are outside the main execution loop (i.e. thread, async task, jupyter cell...) or when you want to force a flush before the end of the execution.

In your case, since you are with-in a synchronous @state.change() method callback, the state will be flushed automatically at the end. No need to do it twice.

My guess is that the @state.change execute your function because vrg_idx is dirty, then within that method, the flush state happen (exit of with state) before the vrg_idx was removed from its dirty state.

Hope that helps,

Seb

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Roadelse
Comment options

Answer selected by Roadelse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants