Make show/hide/toggle etc a Promise
Created by: aersam
Prerequisites
-
I have searched for duplicate or closed feature requests -
I have read the contributing guidelines
Proposal
Currently, If I want to do something a after a modal/offcanvas etc has been show, I need to use events:
const myOffcanvas = document.getElementById('myOffcanvas')
myOffcanvas.addEventListener('shown.bs.offcanvas', event => {
// do something...
// should probably remove that eventListener if no longer needed
})
myOffcanvas.show()
I would be really nice if something like this worked:
const myOffcanvas = document.getElementById('myOffcanvas')
await myOffcanvas.show()
// do something...
Motivation and context
I think most API's in JavaScript are based on Promises these days , and async-await makes them really simple to use. And since IE is dead, we don't even need a transpiler anymore :)
Also, this would not break existing code as long as the events are still emitted. In addition, it's not required to remove events manually which people sometimes forget to do (at least me)