-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Feaure request: return promise from dialogs #1953
Comments
@Christilut sure, it's a good idea |
Just ran into this issue today. I agree that returning a Promise would be a nice addition. |
@jtommy I think this issue is not related to #2539 This one is specifically about This issue is more for a convenience so that you can do simple stuff like
without all the extra boilerplate code in |
@Christilut i'm working on a similar way for the next version 0.9.0 , for example:
https://github.com/buefy/buefy/blob/promise-programmatic/src/components/dialog/index.js#L16 what do you think ? |
I think the following will be possible with 0.9.0 then? const isConfirmed = (await this.$buefy.dialog.confirm({
message: `Are you sure?`,
closeOnConfirm: false
}).result).value Is Personally I wouldn't mind extending the API with something like this (same as in the first post): const confirmed = await this.$buefy.dialog.confirm({
message: `Are you sure?`
}).promise() Because it's just super simple and understandable for new users and isn't in the way for older users who are used to how it is now. |
You can write my previous code in this way: const { confirmed, dialog } = await this.$buefy.dialog.confirm({
message: 'Are you sure?',
closeOnConfirm: false
}).result; closeOnConfirm is only for disable autoclose :) |
Ah okay, looks good then! Put the last snippet (without closeOnConfirm) in an example, I think that will help users a lot :) |
@Christilut sure! |
@Christilut i don't want to add an other breaking so it will be available by const { result, dialog } = await this.$buefy.dialog.confirm({
message: 'Are you sure?',
closeOnConfirm: false
}); |
Very cool, thanks! |
Description
As a heavy Buefy user, I would really like it when the confirm dialog would return a Promise.
My workaround now is simple but not very pretty:
Perhaps for a non-API breaking method we could do it like this (AWS SDK added promises to their library in the same way):
Why Buefy need this feature
This is quite common nowadays. SWAL uses this method and it's very nice to work with. I ditched SWAL when I found out Buefy now has similar programmatic dialog/modal functionality.
The text was updated successfully, but these errors were encountered: