-
Notifications
You must be signed in to change notification settings - Fork 35
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
README: throttle plugin API #1
Conversation
Cool! |
ping @SGrondin 👀 |
octokit.throttle.on('rate-limit', (retryAfter) => console.warn(`Rate-limit hit, retrying after ${retryAfter}s`))
octokit.throttle.on('abuse-limit', (retryAfter) => console.warn(`Abuse-limit hit, retrying after ${retryAfter}s`)) I like it! 👍 |
If you are happy with the API overall, I'd merge this in and we can start the implementation. I'm not very familiar with bottleneck so I hope you can help me out :) One thing that concerns me a little about the |
I'll help as much as I can but I won't be able to write much code since my bandwidth is more limited than I thought. I'll review code and help as much as I can though! Bottleneck has a built in event emitter to get around the fact that browsers don't have one. All I have to do is expose it and then we could use it to add https://github.com/SGrondin/bottleneck/blob/master/lib/Events.js |
Also, I'll add a custom build to Bottleneck just for this project, it'll be something like |
Thanks Simon! |
@gr2m As promised, I've just released Bottleneck 2.14.1, with the features I mentioned above: Custom bundleimport Bottleneck from "bottleneck/light";
Events micro-libraryI've been using this for years to add events in a browser-compatible way without having to rely on a library. It lets you transform any object into an EventEmitter.
Here's a basic example using it inside of a class: class HelloWorld {
constructor() {
this.emitter = new Bottleneck.Events(this);
}
doSomething() {
this.emitter.trigger('info', 'hello', 'world', 123);
return 5;
}
}
const myObject = new Hello();
myObject.on('info', (...args) => {
console.log(args); // ['hello', 'world', 123]
});
myObject.doSomething(); |
Thank you!
That’s not necessary
Is this the code for the Events micro-library? That looks small enough :)
With that you mean it emits the special "error" event in event handlers even if they are async? Or is there more to it? |
Yup :)
Basically I never let errors disappear because that's a nightmare when trying to debug. |
🎉 This PR is included in version 1.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Here we can do some dreamcoding :) Curious how the API should ideally look like
Preview 👀