-
-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[rstream] error handling, subscribe/transform cleanups #279
Merged
Conversation
This file contains 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
BREAKING CHANGE: update ISubscribable contract, remove transducer only version of `.subscribe()`, MUST provide dummy sub w/ transducer OR (better) use `.transform()` instead (which also more clearly communicates intention...) - another breaking change side effect for `.subscribe()`: `next()` handlers MUST be provided now in first arg (child sub), this is NOT because they're mandatory now, but TS won't be able to correctly infer arg types when using `Partial<ISubscriber<T>>` - add `DUMMY` subscriber constant w/ empty `next() {}` - simplify internal `.subscribe()` logic - add `WithErrorHandlerOpts` interface - update `.transform()` & `.map()`: add error handling support
BREAKING CHANGE: replace transducer only version of `PubSub.subscribeTopic()` with new `.transformTopic()`. Similarly to 22c6f7c, `.subscribeTopic()` subs also need to provide at least a `next` key (for typechecking only) - add .transformTopic() w/ opt error handling support - TODO multi-transducer overrides for .transformTopic()
- add new `transform()` override to supply transducer as part of options arg - update/fix opts arg type in other `transform()` versions - add `WithTransform`, `WithErrorHandler` interfaces - update `TransformableOpts`, `WithErrorHandlerOpts`
- update PubSub, PubSubOpts w/ new generic for topic types (default: any)
- replaces obsolete `ISubscribableSubscriber`
BREAKING CHANGE: remove `.subscribe(sub, xform, opts)` signature. Transducer now supplied via `xform` key in `opts` (or use `.transform()` instead of `.subscribe()`) - further simplify `Subscription.subscribe()` / `.transform()` - update Subscription ctor args - make `.subscribe()` child subs partial again - remove temporary & obsolete again `DUMMY` subscriber - add docs - update tests
- update PubSub generics - update .subscribeTopic() opts to use `TransformableOpts`
postspectacular
commented
Mar 6, 2021
packages/rstream/src/api.ts
Outdated
): Subscription<B, F>; | ||
transform<C>( | ||
opts: WithTransform<B, C> & Partial<WithErrorHandlerOpts> | ||
): Subscription<B, C>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This override addresses @jamieowen's comment & use case discussed here: #276 (comment)
10 tasks
- add `ErrorHandler` type, update to return boolean - update `ISubscribable`, `ITransformable` to only refer to `ISubscription` interface (rather than `Subscription` class itself) - refactor `Subscription.next()`, add `.dispatchXform()` - update various error handlers (add return values) - update tests
- add State.UNSUBSCRIBED - add missing Sub2.done() handling - add Sub2.map() - refactor Sub2 value/phase dispatch logic - add logging
- replace old `Subscription` class w/ what was recently `Sub2` (removed) - update/fix done(), subscribe()/unsubscribe() logic - update related constructs (Stream, StreamSync, MetaStream, etc.) - update Stream ctor (and factory fns) to support error handler opts arg - update Timeout error dispatch - fix typehints
- DONE state now only valid during depth-first stage of .done() - state switches to UNSUBSCRIBED during recursive teardown (unless ERROR) - update tests
- update stream() opts arg type - update Stream.subscribe() to use opt error handler to deal w/ errors during execution of stream source function - add test
- add state check in .subscribe() - set both parent & child sub to ACTIVE
- store last received value (if caching enabled) - update error handler logic
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.
Related to ongoing discussion in #276, #279, #281 (see latter for detailed description)