Closed jessepinho closed 3 months ago
Latest commit: ddbb3cfb2a7a4929450d05cde3600d39512efa0f
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Previously, ZQuery provided no way to update items in place when a stream was restarted. Instead, when a stream was restarted, ZQuery would set the state to
undefined
, then start processing streaming responses again.With this PR's change, we can now handle streams a bit more intelligently. ZQuery no longer sets the state to
undefined
when restarting a stream; instead, it calls a newonStart()
reducer (if it's passed tocreateZQuery()
). Similarly, when a stream ends, errors, or is aborted, it calls handlers for those. It also calls anonValue()
reducer when a value is received from the stream.All those reducers are now returned by a
stream
function that consumers pass tocreateZQuery()
, which allows consumers to maintain a JavaScript scope over the life of a stream. This allows you to update streamed items in place, and — in combination withonEnd()
— discard any items from a previous stream that aren't present in the current stream. (See the implementation and docs for more detail.)Before
https://github.com/penumbra-zone/web/assets/1121544/bc55c820-3cc9-4a9c-acdc-ba6ddea0fa75
After
https://github.com/penumbra-zone/web/assets/1121544/d67538c4-4f05-4033-be28-1b26b60952ad
Closes #1090