Skip to content
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
merged 37 commits into from
Mar 12, 2021

Conversation

postspectacular
Copy link
Member

@postspectacular postspectacular commented Mar 5, 2021

Related to ongoing discussion in #276, #279, #281 (see latter for detailed description)

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`
): Subscription<B, F>;
transform<C>(
opts: WithTransform<B, C> & Partial<WithErrorHandlerOpts>
): Subscription<B, C>;
Copy link
Member Author

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)

- 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
packages/rstream/src/sub2.ts Outdated Show resolved Hide resolved
packages/rstream/src/sub2.ts Outdated Show resolved Hide resolved
packages/rstream/src/sub2.ts Outdated Show resolved Hide resolved
packages/rstream/src/subscription.ts Show resolved Hide resolved
packages/rstream/src/sub2.ts Outdated Show resolved Hide resolved
packages/rstream/src/sub2.ts Outdated Show resolved Hide resolved
packages/rstream/src/sub2.ts Outdated Show resolved Hide resolved
- add State.UNSUBSCRIBED
- add missing Sub2.done() handling
- add Sub2.map()
- refactor Sub2 value/phase dispatch logic
- add logging
packages/rstream/src/sub2.ts Outdated Show resolved Hide resolved
packages/rstream/src/sub2.ts Outdated Show resolved Hide resolved
packages/rstream/src/sub2.ts Outdated Show resolved Hide resolved
- 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
@postspectacular postspectacular merged commit 0329b7b into develop Mar 12, 2021
@postspectacular postspectacular deleted the feature/rstream-276 branch March 12, 2021 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants