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(oneFetchye): make even cleaner api for fetchtye #90

Merged
merged 2 commits into from
Feb 5, 2024

Conversation

code-forger
Copy link
Member

@code-forger code-forger commented Jan 22, 2024

Description

Create a new, cleaner, way of imperatively calling fetchye in One App

Motivation and Context

requiring callers to use makeOneServerFetchye is both messy, and incredibly confusing, since this function works in the client too.

Since redux's dispatch must always be in scope for makeOneServerFetchye to be called, this function can be transformed to a thunk generator.

That takes this code:

  loadModuleData: async ({ store: { dispatch, getState }, fetchClient }) => {
    const fetchye = makeOneServerFetchye({
      store: { dispatch, getState },
      fetchClient,
    });

    await fetchye('http://example.com/api/books/');
  },

To this code:

  loadModuleData: async ({ store: { dispatch  }) => dispatch(oneFetchye('http://example.com/api/books/')),

in all relevant contexts.

NOTE: This does not change the api at all, all params that the imperative fetchye made by makeOneServerFetchye took, the thunk generator still takes. You can still await the dispatch, to get back into your hand the exact returned value as before.

This is purely syntactic sugar.

How Has This Been Tested?

Unit tests, run in a tenancy

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (adding or updating documentation)
  • Dependency update

Checklist:

  • My change requires a change to the documentation and I have updated the documentation accordingly.
  • My changes are in sync with the code style of this project.
  • There aren't any other open Pull Requests for the same issue/update.
  • These changes should be applied to a maintenance branch.
  • I have added the Apache 2.0 license header to any new files created.

What is the Impact to Developers Using Fetchye?

Simpler API

@code-forger code-forger requested review from a team as code owners January 22, 2024 17:30
@code-forger code-forger marked this pull request as draft January 22, 2024 17:31
Copy link

codesandbox-ci bot commented Jan 22, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 3fc48ea:

Sandbox Source
quick-install Configuration
fetchye-provider-install Configuration
fetchye-redux-provider-install Configuration
nextjs-fetchye-ssr Configuration

@code-forger code-forger marked this pull request as ready for review February 5, 2024 17:45
@code-forger code-forger merged commit f6ec47e into main Feb 5, 2024
6 checks passed
@code-forger code-forger deleted the feat/dispatchable-fetche branch February 5, 2024 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants