useDialog – Vue.js snippets

TL;DR;

Here’s the link to the gist use/change/modify it.

Have you ever wanted a simple dialog, which is completely custom, but you didn’t want to pull in a package.

But it always looks like a mess to make?

Well worry no more! In todays Vu…


This content originally appeared on DEV Community and was authored by Mykolas Mankevicius

TL;DR;

Here's the link to the gist use/change/modify it.

Have you ever wanted a simple dialog, which is completely custom, but you didn't want to pull in a package.

But it always looks like a mess to make?

Well worry no more! In todays Vue.js snippets post we'll make just that! Don't believe me? Have a look at the finished result!

And this is the API for it:
the api of using dialogs

If you like it here's the explanation on how to write one yourself.

The useDialog.js

The basic premise is, we want a nice api to use dialogs right?

Something that has an expresive api with autocompletion if possible. Something like:

Dialog.myCustomType()
.title('hello')
.onConfirm(() => { //do something })

This is a bit of a whopper of a class, but it's easy to write test for. I've written the basic api. You can change/modify this to your liking.

Thing to improve?

  • Allow multiple onConfirm/onCancel callbacks Quite simple just change the onConfirmCallback to onConfirmCallbacks = [] And then on each call of onConfirm, just push the callback into the stack, and onResolve await all of the callbacks


This content originally appeared on DEV Community and was authored by Mykolas Mankevicius


Print Share Comment Cite Upload Translate Updates
APA

Mykolas Mankevicius | Sciencx (2021-06-11T05:27:47+00:00) useDialog – Vue.js snippets. Retrieved from https://www.scien.cx/2021/06/11/usedialog-vue-js-snippets/

MLA
" » useDialog – Vue.js snippets." Mykolas Mankevicius | Sciencx - Friday June 11, 2021, https://www.scien.cx/2021/06/11/usedialog-vue-js-snippets/
HARVARD
Mykolas Mankevicius | Sciencx Friday June 11, 2021 » useDialog – Vue.js snippets., viewed ,<https://www.scien.cx/2021/06/11/usedialog-vue-js-snippets/>
VANCOUVER
Mykolas Mankevicius | Sciencx - » useDialog – Vue.js snippets. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/06/11/usedialog-vue-js-snippets/
CHICAGO
" » useDialog – Vue.js snippets." Mykolas Mankevicius | Sciencx - Accessed . https://www.scien.cx/2021/06/11/usedialog-vue-js-snippets/
IEEE
" » useDialog – Vue.js snippets." Mykolas Mankevicius | Sciencx [Online]. Available: https://www.scien.cx/2021/06/11/usedialog-vue-js-snippets/. [Accessed: ]
rf:citation
» useDialog – Vue.js snippets | Mykolas Mankevicius | Sciencx | https://www.scien.cx/2021/06/11/usedialog-vue-js-snippets/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.