doseofted / prim-rpc

Easy-to-understand, type-safe, transport-agnostic RPC/IPC for JavaScript, supporting callbacks, batching, file handling, custom serialization, and more.
https://prim.doseofted.me
Apache License 2.0
98 stars 1 forks source link

Disabled Feature: Handle Unresolved Promises In RPC Result #64

Closed doseofted closed 8 months ago

doseofted commented 1 year ago

[!NOTE]

This feature has been added but is disabled by default in the released module (placed behind experimental .flag in options. The ability to upgrade HTTP to WebSocket will need to be added to RPC plugins before this feature can be utilized (otherwise this only works with the callback handler today).

When returning a result from a function, today it's generally expected in Prim+RPC that all promises contained in the result have already been resolved and those promise wrappers have been removed.

However, when working with multiple promises, it may be more beneficial to the client to return quickly with multiple unresolved promises and simply resolve each promise individually (for instance when rendering data to a UI where data should be displayed as soon as it becomes available).

This PR adds Promises as a new "serializable" type, like blobs or callbacks. It will behave very similarly to callbacks.

changeset-bot[bot] commented 1 year ago

🦋 Changeset detected

Latest commit: c7716bdc3e79e66890ec533ac4abb5b1c868560d

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

This PR includes changesets to release 2 packages | Name | Type | | ------------------------------ | ----- | | @doseofted/prim-rpc | Patch | | @doseofted/prim-example-server | 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

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
prim-rpc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 23, 2024 5:24pm