-
Notifications
You must be signed in to change notification settings - Fork 98
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
Promise and Async/Await Support #80
Comments
For anybody who wants to manually promisify the library, just insert this snippet somewhere in your code after your arrive.js import: const objects = [HTMLElement, NodeList, HTMLCollection, HTMLDocument, Window];
const promisifiedArrive = function(a, b) {return new Promise((resolve) => {this.arriveWithCallback(a, b, resolve);})};
const promisifiedLeave = function(a, b) {return new Promise((resolve) => {this.leaveWithCallback(a, b, resolve);})};
objects.forEach(object => {
object.prototype.arriveWithCallback = object.prototype.arrive;
object.prototype.leaveWithCallback = object.prototype.leave;
object.prototype.arrive = promisifiedArrive;
object.prototype.leave = promisifiedLeave;
}); The following will now work: const element = await document.arrive('#elementId', {onceOnly: true, existing: true});
// do stuff with element |
I went ahead and added async/await support myself and created a PR: #81 |
For any future issue readers: the dev branch on this repo adds this functionality. If you don't need to use npm, arrive.js(dev) contains these changes |
Thank you guys! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not sure if this is possible, or if it is already implemented. It would be nice to use Async/Await with this library.
Example
Instead of this:
The text was updated successfully, but these errors were encountered: