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

feat(core): Implement mapExchange (replacing errorExchange) #2846

Merged
merged 9 commits into from
Dec 1, 2022

Conversation

kitten
Copy link
Member

@kitten kitten commented Dec 1, 2022

Supersedes #1743

Summary

This avoids the breaking change in #1743 and finally replaces it with a complete mapExchange implementation that's similar but doesn't change the debugExchange.

The mapExchange is API-backwards compatible with the errorExchange and the errorExchange's export has been replaced with mapExchange.

The mapExchange exposes three options it accepts:

  • onOperation: Allowing it to react to and replace operations
  • onResult: Allowing it to react to and replace results
  • onError: Allowing it to react to errors on results

The onError option is provided for backwards-compatibility with the errorExchange

The onOperation and onResult functions may respectively,

  • return undefined | void which will cause them to not replace the incoming operations/results
  • return new operations/results, which will replace the incoming ones, allowing it to remap them
  • return promisified operations/results, which allows them to replace operations and results asynchronously, awaiting the promise they return

Set of changes

  • Implement mapExchange
  • Replace errorExchange export with mapExchange
  • Update docs

@kitten kitten merged commit 60b3efd into main Dec 1, 2022
@kitten kitten deleted the feat/map-exchange branch December 1, 2022 13:30
@github-actions github-actions bot mentioned this pull request Dec 1, 2022
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