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: support functional rollbackOnError #2242

Merged
merged 4 commits into from
Nov 23, 2022

Conversation

huozhi
Copy link
Member

@huozhi huozhi commented Nov 13, 2022

Resolves #2093

Support both boolean value and functional value for rollbackOnError for mutate options. This will let users to control rollback on error behavior based on specific error

const newData = createNewData(...)
mutate(key, updateFn(newData), {
    populateCache: true,
    optimisticData: newData,
    rollbackOnError(error) {
        return error.name !== 'AbortError'
    },
})

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 13, 2022

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 036a850:

Sandbox Source
SWR-Basic Configuration
SWR-States Configuration
SWR-Infinite Configuration
SWR-SSR Configuration

@huozhi huozhi marked this pull request as ready for review November 13, 2022 18:27
@huozhi huozhi requested a review from shuding as a code owner November 13, 2022 18:27
@huozhi huozhi requested review from promer94 and koba04 November 13, 2022 18:45
@koba04
Copy link
Collaborator

koba04 commented Nov 14, 2022

@huozhi Do you think currentData is necessary as its argument? It's based on the original feedback in #2092, but if it doesn't have any use case, it might be better to add it later when necessary.

@huozhi
Copy link
Member Author

huozhi commented Nov 14, 2022

@koba04 sounds good, erased it from arguments

Copy link
Collaborator

@koba04 koba04 left a comment

Choose a reason for hiding this comment

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

👍 LGTM!!!

Copy link
Member

@shuding shuding left a comment

Choose a reason for hiding this comment

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

🙇‍♂️

@shuding shuding merged commit 3606785 into main Nov 23, 2022
@shuding shuding deleted the feat/functional-rollback-on-error branch November 23, 2022 11:41
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.

rollbackOnError as function
4 participants