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

New withCalls enabled prop #134

Closed
gabrielguerrero opened this issue Sep 17, 2024 · 1 comment · Fixed by #135
Closed

New withCalls enabled prop #134

gabrielguerrero opened this issue Sep 17, 2024 · 1 comment · Fixed by #135
Labels
enhancement New feature or request released

Comments

@gabrielguerrero
Copy link
Owner

This is to add a new prop to the typedCallConfig of withCalls called enabled, which will receive a function that receives the params and can return a boolean or Observable or Promise, if true, the call is executed as usual if false the call is ignored and no state changes will be made, useful for cases where the call should be skipped if the param is null, or if the call for the give param was already cached.

Example:

  withCalls(() => ({
    loadProductDetail: typedCallConfig({
      call: ({ id }: { id: string }) =>
        inject(ProductService).getProductDetail(id),
      resultProp: 'productDetail',
      enabled: ({ id }) => !!id,  // will only execute if the id is not null
    }),
  })),
@gabrielguerrero gabrielguerrero added the enhancement New feature or request label Sep 17, 2024
gabrielguerrero pushed a commit that referenced this issue Sep 17, 2024
New enabled function in withCalls config allows to skip the call under certain user defined
conditions like when params are null, or result was already cached

fix #134
gabrielguerrero pushed a commit that referenced this issue Sep 18, 2024
New enabled function in withCalls config allows to skip the call under certain user defined
conditions like when params are null, or result was already cached

fix #134
gabrielguerrero pushed a commit that referenced this issue Sep 18, 2024
New skipWhen function in withCalls config allows to skip the call under certain user defined
conditions like when params are null, or result was already cached

fix #134
Copy link

🎉 This issue has been resolved in version 18.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant