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

[REFACTOR] introduces ApiRequest and dynamic dispatch across implementations #19

Conversation

withtwoemms
Copy link
Owner

Summary:

There are different ways to make a request. The convenience of the old PokeApiRequest is that it is allows for separation between the declaration of the request and its invocation. This general structure is captured by the new DeferredRequest protocol. The ApiRequest enum is introduced as an encapsulation of the various DeferredRequest implementations. Dynamic dispatch across implementations can be implicitly controlled by setting the "API_REQUEST_IMPL" environment variable.

Notes:

  • implicit control of implementation dispatch was chosen as it's the simplest path towards runtime control of request behavior. In the future, consideration could be given to an explicit rendition which would necessitate changes in the function signatures of pokedex.api.client members and would relieve dependence on test mocks.

@withtwoemms withtwoemms merged commit cc8d34d into main Jan 4, 2024
4 checks passed
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

1 participant