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

Expose a higher level timer to wrap gauge #7

Open
msaspence opened this issue Jul 22, 2016 · 4 comments
Open

Expose a higher level timer to wrap gauge #7

msaspence opened this issue Jul 22, 2016 · 4 comments
Assignees
Labels

Comments

@msaspence
Copy link

Something like:

// Synchronous 
barometer.timer('path', function() {
  thingToBeTimed();
});
// Asynchronous with callback
barometer.timer('path', function (done) {
  thingToBeTimed(function() {
    done();
  });
});
// Asynchronous with promise
barometer.timer('path', function (done) {
  return thingToBeTimed();
});
@theninj4
Copy link
Contributor

First up, I love the idea of removing the hassle around timing something. My immediate reaction to this was around promises requiring a polyfill. I wonder how small a Promises polyfill is... If it's not an order of "tiny", I wonder if it'd be best to add features like this asynchronously after the page has loaded. We need the core script to load first to ensure we get page events before everyone else, I guess that doesn't mean we have to actually do anything else at that point.

@msaspence
Copy link
Author

Yeah I also think the idea of a "two stage load" is interesting. I wonder if there is anything currently in the core script that could be moved into a subsequent phase?

@theninj4
Copy link
Contributor

I'm actually really impressed at how far UglifyJS and JSCrush can compress code, we might get away with more than I expect. Promises aside, this is worth implementing as usual. How about we only support Promises if they're supported natively?

@msaspence
Copy link
Author

Yes but rather than saying "are these supported natively" can we duck type the returned value. i.e. if it exposes a promise like interface, we will treat it as such, this allows the application to load its own polyfill for Promises before any calls to timer. If the calling code is returning a promise and either the browser doesn't Promises or they have loaded a polyfil we don't have to worry.

@hx-emanolov hx-emanolov self-assigned this Jul 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants