How can I cache outputs when parameters inside a widget change?

Say you have this:

My goal is to change input in X (e.g., to 3) and have it say:

  • Current result: 9
  • Previous result: 6

Then, when I change X to 4, it will say:

  • Current result: 12
  • Previous result: 9

Does anyone know how to do this please?

HI @mogortevo ,

If I understood you correctly, probably session-state will do the trick.Try to store your variable Previous result using session_state.