-
Notifications
You must be signed in to change notification settings - Fork 32
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
Have problems with promisified chrome.contextMenus.create method #23
Comments
@q00n well spotted - that method has a slightly different pattern to most. The common pattern (in TS syntax) looks something like However, I think this method (and any others where the callback doesn't get passed the result) need a different promisify function. |
The await keyword will work fine with the `create` function's return (without a Promise), so by skipping the Promisification of this function, it will work in more cases, namely when used with async/await. Unfortunately, this won't work with promise chaining (using `then()`), but that can be managed by wrapping the function with `Promise.resolve()`. I have another idea about how that could also be tackled... I'll open a separate PR in a bit. Fixes KeithHenry#23.
This is an alternative approach to fixing KeithHenry#23. For chrome functions that pass no arguments to their callbacks, we should try to propagate the function's own return value. Honestly, I'm pretty confused about how it is even able to work. It makes sense, kind of, but I'm surprised that I can access the function return inside an arrow function defined as an inline function argument. In any case, I tested and confirmed that this works. Fixes KeithHenry#23 and closes KeithHenry#26.
This is pretty old now, but as @KeithHenry pointed out, it seems that While this project could absolutely implement a completely separate promisify function, I had a couple ideas for working with the existing one:
I recommend #27. 🙂 |
This is an alternative approach to fixing KeithHenry#23. For chrome functions that pass no arguments to their callbacks, we should try to propagate the function's own return value. Honestly, I'm pretty confused about how it is even able to work. It makes sense, kind of, but I'm surprised that I can access the function return inside an arrow function defined as an inline function argument. In any case, I tested and confirmed that this works. Fixes KeithHenry#23 and closes KeithHenry#26.
This is an alternative approach to fixing KeithHenry#23. For chrome functions that pass no arguments to their callbacks, we should try to propagate the function's own return value. Honestly, I'm pretty confused about how it is even able to work. It makes sense, kind of, but I'm surprised that I can access the function return inside an arrow function defined as an inline function argument. In any case, I tested and confirmed that this works. Fixes KeithHenry#23 and closes KeithHenry#26.
Hi, promisified
chrome.contextMenus.create
method doesn't returns id of the created menuThe text was updated successfully, but these errors were encountered: