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

SSE API to see when cache is updated #46

Open
dpwspoon opened this issue Aug 24, 2017 · 2 comments
Open

SSE API to see when cache is updated #46

dpwspoon opened this issue Aug 24, 2017 · 2 comments

Comments

@dpwspoon
Copy link
Contributor

No description provided.

@hthetiot hthetiot modified the milestones: Future, 1.0.2 Enhancements Aug 30, 2017
@dpwspoon
Copy link
Contributor Author

dpwspoon commented Sep 6, 2017

Possible options

Before (A) - schedule repeating XHRs at fixed interval

var sendXHR = function(...)
{
  var xhr = new XMLHttpRequest();
  ...
  xhr.send("");
};
window.setInterval(sendXHR, 30)

Before (B) - chain next XHR after previous XHR

var sendXHR = function(...)
{
  var xhr = new XMLHttpRequest();
  ...
  xhr.send("");
  xhr.onload = function() { ...; setTimeout(sendXHR, 30); };
};

After (1)

var sendXHR = function(...)
{
  var xhr = new XMLHttpRequest();
  ...
  xhr.oncachechanged = sendXHR;  
  xhr.send("");
};

After (2) - defers response when previous answer already known

var sendXHR = function(...)
{
  var xhr = new XMLHttpRequest();
  ...
  xhr.setRequestHeader("Prefer", "wait=30"); // RFC 7240
  xhr.send("");
  xhr.onload = function() { ...; sendXHR(...); };
};

@dpwspoon dpwspoon removed this from the 1.0.2 Enhancements milestone Sep 9, 2017
@hthetiot
Copy link
Contributor

Possible progress event use case.
Source: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType
screen shot 2017-10-23 at 3 25 48 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants