agents icon indicating copy to clipboard operation
agents copied to clipboard

Can onStateUpdate include the prev state?

Open kchro3 opened this issue 8 months ago • 1 comments

I have a case where I'd like to handle specific types of updates, so if the state is an object, i want to handle a change to a field.

However, I think I need access to the previous state in order to see if the field had changed.

Proposed:

  onStateUpdate(state: State | undefined, prevState: State | undefined, source: Connection | "server") {
    if (state?.field !== prevState?.state) {
      // do something
    }
  }

kchro3 avatar May 12 '25 22:05 kchro3

yeah we could do this. might have to put prevState as the last arg so it's not a breaking change. wanna make a PR?

threepointone avatar May 13 '25 11:05 threepointone

@kchro3 is it something that you still need?

whoiskatrin avatar Sep 11 '25 08:09 whoiskatrin

Closing due to no activity. Let us know if you'd be up for doing this and if you still need it.

whoiskatrin avatar Sep 23 '25 15:09 whoiskatrin