penumbra-zone / web

Apache License 2.0
10 stars 7 forks source link

Tweak getters to allow .optional() to be called at any point in a getter chain #1288

Closed jessepinho closed 2 weeks ago

jessepinho commented 2 weeks ago

Well, this turned out to be easier than expected!

Previously, we couldn't call .optional() at just any point in a getter chain; instead, we had to call it on the first getter in the chain. e.g.,

const myGetter1 = getter1.optional().pipe(getter2).pipe(getter3) // Will truly be optional
const myGetter2 = getter1.pipe(getter2).pipe(getter3).optional() // Will throw if any getter in the chain returns `undefined`

With this PR's change, .optional() can now be called at any point in the chain, and it will work as expected!

Closes #1153

changeset-bot[bot] commented 2 weeks ago

🦋 Changeset detected

Latest commit: 22a869de9edf1efd5a1be91c9433f335a720b406

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages | Name | Type | | ------------------------------- | ----- | | @penumbra-zone/getters | Minor | | minifront | Patch | | @penumbra-zone/perspective | Patch | | @penumbra-zone/query | Patch | | @penumbra-zone/services | Patch | | @penumbra-zone/storage | Patch | | @penumbra-zone/types | Patch | | @penumbra-zone/ui | Patch | | chrome-extension | Patch | | @penumbra-zone/services-context | Patch | | node-status | Patch | | @penumbra-zone/crypto-web | Patch | | @penumbra-zone/wasm | Patch |

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](https://github.com/penumbra-zone/web/new/jessepinho/better-optional-getters-dx-web-1153?filename=.changeset/tricky-buttons-search.md&value=---%0A%22%40penumbra-zone%2Fgetters%22%3A%20patch%0A---%0A%0ATweak%20getters%20to%20allow%20.optional()%20to%20be%20called%20at%20any%20point%20in%20a%20getter%20chain%0A)