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

fresh() doesn't call any lifecycle Hook #1722

Open
abd777 opened this issue Nov 1, 2023 · 3 comments
Open

fresh() doesn't call any lifecycle Hook #1722

abd777 opened this issue Nov 1, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@abd777
Copy link

abd777 commented Nov 1, 2023

Environment

No response

Reproduction

Playground

Describe the bug

I need to listen for the lifecycle hook inside the Model when the fresh() is called , but no any lifecycle hook is listening to fresh() while if i use save() it works

For now i'm using this as a workaround

const repo = useRepo(REPO_NAME)
// clear everything
repo.flush()
// then save , i.e to trigger the lifecycle
repo.save(NEW_DATA)

ideally fresh() should also be a lifecycle hook trigger

Additional context

No response

Logs

No response

@harmyderoman
Copy link

Actually, it can be useful, if you have one mutator that doesn't trigger the hooks. For example, if you need to save raw data from a backend.

@abd777
Copy link
Author

abd777 commented Nov 25, 2023

@harmyderoman I agree with you , But the issue is that in most cases we need to check the hooks ( as we're using saving
and other hooks for other functions )

May be we can add an optional raw parameter like {raw:true} as the last config object and if raw is true we can keep it as it is , otherwise we can listen for the hooks

@CodeDredd
Copy link
Owner

Hmmm interesting. I try to get my thoughts around that. You both have valid points.
I think flush is getting hooks and i also add the option to avoid hooks.

@CodeDredd CodeDredd added enhancement New feature or request and removed pending triage labels Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants