question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support short polling

See original GitHub issue

Sometimes it might be handy to refresh query data, which could allow to have more “real-time” user experience. This is how I would go about it:

  1. To RequestAction add meta.pool: number (in seconds), this would be an interval, how often queries should be refetched automatically
  2. We could implement it as a separate middleware (probably it would go even as 1st one in the stack)
  3. Of course this middleware should be disabled when running with ssr: 'server'
  4. PollingMiddleware would just pass all actions through, but also it would check for queries with meta.poll, for which it would activate setInterval, repeating those actions, dispatching them again after x seconds
  5. I think that dispatched query from this new middleware could also add meta.pollCounter: number, it could show us which time a given query is repeated, and also this could prevent poll looping - we shouldn’t create interval again for a query which is result of this middleware, otherwise we would have multiple intervals for the same query
  6. Making a new request of the same type (type + requestKey) without meta.pollCounter should clear current interval (it really means than a new query was dispatched, not from middleware but outside), and, depending on meta.poll, possibly set new interval
  7. we should add stopPolling action which should have the same arguments like for example abortRequests
  8. probably new flag should be added to resetActions but for now I won’t provide details as resetActions is work in progress on pure-react branch

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:21 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
klis87commented, Jan 17, 2021

@iwan-uschka @favger released in https://github.com/klis87/redux-requests/releases/tag/%40redux-requests%2Fcore%401.5.0

note that I didn’t implement pause and resume polling actions, because it can be just achieved by dispatching stopPolling and then, in a proper time by dispatching a given query with meta.poll again

2reactions
klis87commented, Jan 13, 2021

Just in case, if anyone started working on this, please let me know, as probably this is the next on my list, as I just published new version focused on React. If not, that’s totally fine, I just don’t want to duplicate our efforts 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Amazon SQS short and long polling - AWS Documentation
Learn about the benefits of using Amazon SQS long polling to eliminate empty responses and false empty responses and to reduce your costs....
Read more >
What is Long Polling and Short Polling ? - GeeksforGeeks
Short Polling : In a short polling client requests data from the server and ... We will understand short polling with the help...
Read more >
Understand and Implement Long-Polling and Short Polling in ...
HTTP polling is a technique that we can use to build our real-time apps. In this article, you will read about what is...
Read more >
Long and Short Polling
Short Polling. ○ Client makes a request to the server ... Short polling is an AJAX-based timer that calls at fixed delays ......
Read more >
Short Polling vs Long Polling vs Web Sockets
Device support and fallbacks. Web Sockets. WebSocket is a computer communication protocol that provides full-duplex communication channels over ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found