📝 Add Library Integration guide for Promise-based API pattern#1133
Open
📝 Add Library Integration guide for Promise-based API pattern#1133
Conversation
82e6674 to
d68edcc
Compare
commit: |
Add documentation for using Effection inside a library while exposing a traditional Promise-based API to clients. The pattern uses createScope(), withResolvers(), resource(), and suspend() to bridge between Effection's structured concurrency and async/await. - Create docs/library-integration.mdx with full pattern and example - Add to Advanced section in structure.json - Add cross-reference from scope.mdx - Add FAQ entry pointing to the guide
d68edcc to
6fd23cf
Compare
cowboyd
reviewed
Mar 2, 2026
Comment on lines
+76
to
+78
| if (closed) { | ||
| throw new Error("Pool is shut down"); | ||
| } |
Member
There was a problem hiding this comment.
Code like this should never appear inside an Operation since this is the point of structured concurrency. The lifetime of code does not need to be track apart from its own execution. If this check is necessary, it should happen at the promise layer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
A community member asked in Discord: "Do you have any recommendations for using Effection inside a library, while exposing a more traditional API to the clients?"
This is a common use case that deserves dedicated documentation. The pattern evolved through discussion and is now captured in a gist, but should live in the official docs.
Approach
Add a new "Library Integration" guide to the Advanced section covering the pattern for using Effection internally while exposing a Promise-based API:
createScope()as the integration pointwithResolvers()to synchronize initialization and prevent race conditionsresource()for lifecycle managementsuspend()to keep the scope alive between callsscope.run()as the bridge to PromisesSymbol.asyncDisposeforawait usingsupportChanges:
docs/library-integration.mdxwith the full pattern and connection pool exampledocs/structure.jsondocs/scope.mdx(in the "Creating a brand new Scope" section)docs/faq.mdxpointing to the guideThe guide includes gotchas identified during review:
closedflag)destroy()for cleanup completion