-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Support short polling #418
Comments
@favger Thx for the snippet. I can see you use React, so you might be interested that additionally @iwan-uschka @favger the only thing I am wondering, should we only have
I don't wanna introduce Theoretically though, we could introduce |
@klis87 I cannot think of any use case right now where I had to create an async loop mechanism this year myself. I just created a gist you can look at. I am using an iterator function and we can configure the behaviour like this
Perhaps for inspiration :) And @favger: checking |
@iwan-uschka Thx for the feedback. Regarding abortRequest, I prefer to keep this only to just abort requests, no matter whether polling is used or not. Hence I think dedicated action stopPolling would be cool. However, resetRequests should stop all polling, I cannot think about any case which would reset a request just to make another with polling. And thanks for the gist :) @favger actually very cool idea with isWindow active, we could have actions like pausePolling and resumePolling! This is probably nice to have TODO, for the future, but it makes sense not to pool when sth is not visible! |
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 :) |
@iwan-uschka @favger btw, I am interested on your opinion about #432 , I would really appreciate your feedback! |
@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 |
@klis87 I tested it, it works fine. How would you recommend not to stop automatic renewal, except for the browser tab only? |
@favger you mean to stop polling when a browser tab is not active? |
@klis87 Yes, definitely |
@favger probably you would need to use
if this works, we could think of an extra prop like |
@klis87 I already use a similar structure as you said, but having a shorter method may be more comfortable for the developer. Thank you very much for your support. |
@favger Thank you as well for contributing with valid issues and ideas! Once you set this up, please share some snippet, so I will make this easier to support! |
We can solve it this way;
meta.poll= 10
I hope that has been revealing. |
@favger ok, so you have a global way to get this attr. So, I guess extra prop to
Adding the same in Perhaps this actually should be solved on Redux layer (in the core)... For now I am pretty sure you could create |
@klis87 excellent |
Hope it's not too late to join the party. Installed & tested I want to make a suggestion for an improvement because as a developer i probably want to handle requests differently depending on the use case and respecting potentially network issues. Before giving some examples i would like to give a quick reminder of the configuration matrix i mentioned at the beginning of this thread:
@klis87 , you implemented the Another example: short timed polling, for instance @klis87 , if you like i could come up with a proposal or pull request including these options. We can discuss about the naming of course, or if |
@iwan-uschka I don't have enough time to analyze your post tonight long enough unfortunately, I will try to do it tomorrow, but I will answer now as you mentioned very important topic which I feel is related to sth else and will be compatible with your suggestion. See #416 for my effects proposal, for example with Anyway, right now I am working on subscriptions, which probably will be used more often than polling anyway for real-time functionality. |
@iwan-uschka I analyzed your interval type suggestion and I think that:
Is it necessary to support both |
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:
RequestAction
addmeta.pool: number
(in seconds), this would be an interval, how often queries should be refetched automaticallyssr: 'server'
PollingMiddleware
would just pass all actions through, but also it would check for queries withmeta.poll
, for which it would activatesetInterval
, repeating those actions, dispatching them again afterx
secondsmeta.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 querymeta.pollCounter
should clear current interval (it really means than a new query was dispatched, not from middleware but outside), and, depending onmeta.poll
, possibly set new intervalstopPolling
action which should have the same arguments like for exampleabortRequests
resetActions
but for now I won't provide details asresetActions
is work in progress onpure-react
branchThe text was updated successfully, but these errors were encountered: