Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • thank you, this works for most of the stuff. I probably could've written it different. How about if I have a map? When I scroll through the map, it sends requests for checkpoints (so I can display them). I want to send only the last request (when scrolling stops) Commented Jun 20, 2018 at 11:51
  • I expressed myself wrongly in the comment. Basically what I meant was, that I don't want to send another request until the last request has been processed. For example, I click on maps and it sends request to server for checkpoints. Even if server hasn't given me back response I can scroll and drag the map around. Every move on google maps makes another request even if the last one has not been processed. I first want to process the last request before sending another, is that achievable using unsubscribe? Commented Jun 20, 2018 at 12:03
  • If you want to ignore intermediate requests you can just check if this.subscription == undefined. if true ? make the request, otherwise : ignore. Commented Jun 20, 2018 at 12:06
  • yea this works for ignoring all requests, I still need to execute the last request (when the user stop scrolling/dragging) Commented Jun 22, 2018 at 11:38
  • Then you need to save all the latest parameters to a variable and check if this variable is set when completing your last request. If so: execute the request with the latest parameters in the variable. Commented Jun 22, 2018 at 12:18