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

Add response interceptors #6

Merged
merged 2 commits into from Jul 6, 2022
Merged

Add response interceptors #6

merged 2 commits into from Jul 6, 2022

Conversation

alexmazlov
Copy link
Contributor

The original idea comes from Apollo Interceptors where the network service allows external introspection of request before the are handed over to the original caller. This allows the calling framework to centrally react to all responses which may contain the same data values within multiple endpoints (e.g access token structures attached to various types of response models). The idea is the interceptor would observe the response data and request that was originally made and then decide weather it contains a central data item that needs or even if the response needs to be modified to enforce a lack congruity on the back-end.

Copy link
Contributor

@MattKiazyk MattKiazyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one typo!

@@ -17,6 +17,9 @@ public protocol AsyncNetworkService: AnyObject {

/// if this is set, all network requests returned with an error will loop through the list.
var errorHandlers: [AsyncNetworkErrorHandler] { get set }

/// if this is set, all network reponses returned with success will call `handle` on these interceptors
var reponseInterceptors: [NetworkResponseInterceptor] { get set }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var reponseInterceptors: [NetworkResponseInterceptor] { get set }
var responseInterceptors: [NetworkResponseInterceptor] { get set }

@alexmazlov alexmazlov merged commit bc03565 into main Jul 6, 2022
@alexmazlov alexmazlov deleted the alex/response-interceptor branch July 6, 2022 21:51
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.

None yet

2 participants