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

usePoll - Manual Polling not triggering start/stop outside standalone button. #2272

Open
kinger251285 opened this issue Mar 10, 2025 · 0 comments

Comments

@kinger251285
Copy link

kinger251285 commented Mar 10, 2025

Version:

"@inertiajs/vue3": "^2.0.5"

Describe the problem:

usePoll manual polling not recognising start or stop unless using a standalone button.

import {usePoll } from '@inertiajs/vue3';

const props = defineProps({  
  syncInProgress: Boolean,
  liveInProgress: Boolean,   
}); 

const { stop, start } = usePoll(1000, { 

  onStart() {
      console.log('Polling request started')
  }, 
  only: ['syncInProgress', 'liveInProgress'] }, 
  {
    autoStart: false,
});

function sync () {
  start();
  router.get('/admin/product-sync');
};

This does not trigger the polling to start. However if i add a standalone button as per the docs example then polling starts.

<template>
    <button @click="start">Start polling</button>
    <button @click="stop">Stop polling</button>
</template>

This works.

However this does not:

<template>
    <button @click="sync(), start">Start polling</button>
</template>

Further to this oddly if i call a function from a standalone button as below it works fine. Yet if i call that function with another or from another function then it does not work:

function startPolling () {
  start();
};

<template>
    <button @click="startPolling()">Start polling</button>
</template>
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

No branches or pull requests

1 participant