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

Add an idle property to objects. #894

Merged
merged 2 commits into from
Aug 14, 2018
Merged

Add an idle property to objects. #894

merged 2 commits into from
Aug 14, 2018

Conversation

manthey
Copy link
Contributor

@manthey manthey commented Aug 14, 2018

For any object that inherits from geo.object, the idle property is true if onIdle would call a handler immediately.

For any object that inherits from geo.object, the `idle` property is
true if `onIdle` would call a handler immediately.
@manthey
Copy link
Contributor Author

manthey commented Aug 14, 2018

@matthewma7 This allows doing something like

var nexturl;
function (osmLayer, newurl) {
  if (nexturl) {
    nexturl = newurl;
  } else if (osmLayer.idle) {
    osmLayer.url(newurl); 
  } else {
    nexturl = newurl;
    osmLayer.onIdle(function () {
      if (nexturl) {
        osmLayer.url(nexturl);
      }
      nexturl = null;
    });
  }
}

Though this would work identically (if slightly less efficiently) with the current code without the two lines

  } else if (osmLayer.idle) {
    osmLayer.url(newurl); 

@matthewma7
Copy link

Thanks @manthey
I tried to flood the request, but it seems the queue in the Network tab won't go too long already. Is the osmLayer internally tracking pending requests already?
This PR is good as itself, but do you think I still need it?

@manthey
Copy link
Contributor Author

manthey commented Aug 14, 2018

The tile layer will never have more than 6 tiles pending at a time (this number is configurable). When you switch url, I don't know if it will queue a new set of 6 tiles before the extant ones complete -- the browser will block if they are from the same server.

I think the PR adds a nice property, so I'd say it should still be added.

@matthewma7
Copy link

Yes, I observe what you said, the queue won't grow crazy.

This PR is good. Thanks for prompt improvement upon request 😉

@manthey manthey merged commit 7d93da4 into master Aug 14, 2018
@manthey manthey deleted the idle-property branch August 14, 2018 18:40
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

Successfully merging this pull request may close these issues.

2 participants