8000 Add a hooks system to `useQuery` · Issue #309 · posva/pinia-colada · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Add a hooks system to useQuery #309
Closed as not planned
Closed as not planned
@Barbapapazes

Description

@Barbapapazes

Hey 👋,

Currently, the hooks system (onSeattled, onSuccess) is only available when using onMutation but having it for useQuery could be very useful.

For example, if I want to start and finish the Nuxt loading indocator, I have to use a watcher on the asyncStatus props.

const { asyncStatus } = useQuery(...)

const { start, finish } = useLoadingIndicator()
watch(asyncStatus, (status) => {
  if (status === 'loading') {
    start()
  } else {
    finish()
  }
})

It could be more convenient to have this directly in the useQuery to make sure that everything is tight.

For example:

const { start, finish } = useLoadingIndicator()
const {} = useQuery({
  onQuery: () => start()
  onSettled: () => finish()
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0