Part I of a new major release proposal #516
var clipboard = new Clipboard('.btn');
clipboard.on('success', function(e) {
// it worked
});
clipboard.on('error', function(e) {
// it didn't work
});
clipboard.copy('.btn')
.then(function(e) {
// it worked
})
.catch(function(e) {
// it didn't work
})
This change will make the API more modern, remove tiny-emitter dependency, and help those who need to make actions before copying (for example, make an ajax request).
This change will drop support for IE: https://caniuse.com/#search=promises
Can you use bluebirdjs, or a polyfill to continue IE support?
@vinhboy I think it would be better to advise people to include a promise polyfill separately if they need it
I agree with @ClementParis016, if we add a polyfill by default the bundle will be huge. We'll probably advise people to include themselves.
I'm a little confused, am I?
a Promise is only ever resolve once..
So with this implementation if a user clicks on the button multiple times you would only ever catch the first click event?
This change will make the API more modern
I'm also confused, for the same reason as @vidhill. Promises are not just "modern" replacements for events.
and help those who need to make actions before copying (for example, make an ajax request)
Is this not already possible?
Most helpful comment
@vinhboy I think it would be better to advise people to include a promise polyfill separately if they need it