Comments (9)
Hello @STUkh @tradingstratagem
I can confirm the issue that was reported, and here is a reproducing jsfiddle: https://jsfiddle.net/rd5ef4t1/1/
I think there was a misunderstanding on the issue. Here the JSfiddle is based on the index.html/example.js files from the vue-promise-btn demo. The directive works well when the handler function doesn't need any argument. However when we pass any argument to the handler, the handler returns "undefined" instead of returning the promise, thus the directive isn't working.
It seems to me that the problem is very similar to this issue that you previously solved @STUkh vuejs/vue#7705 because when I look the generated code for my handlers, I get:
Without arguments, valid return:
on:{"click":function($event){$event.preventDefault();return dummyAsyncAction($event)}}}
With arguments, missing return:
on:{"click":function($event){$event.preventDefault();dummyAsyncAction('arg')}}}
It seems that the "return" is missing for handlers with arguments, what do you think?
from vue-promise-btn.
Please, create gist with example. Everything should be fine with your case.
from vue-promise-btn.
https://gist.github.com/tradingstratagem/fa6b6af7496867be1b9560e9bc4f487c
from vue-promise-btn.
@tradingstratagem your app logic a little bit incorrect. Click event should accept function that returns promise, instead of promise instance itself.
from vue-promise-btn.
The example uses the same mechanism
https://github.com/STUkh/vue-promise-btn/blob/master/example/example.js
from vue-promise-btn.
@tradingstratagem in your case, function with params should looks like this:
function test (param1) {
// return anonymous function that will be triggered on click from view with "param1" in closure
return function () {
return new Promise(function (res, rej) { setTimeout(function () { res() }, 2000) });
}
}
from vue-promise-btn.
I tried but nothing happens
from vue-promise-btn.
@tradingstratagem i've just tested on my own project - all works properly. Close this thread, fell free open new one with jsfiddle or jsbin example if you face this problem again.
from vue-promise-btn.
@SebastienTainon , @tradingstratagem - you can try v2.0.0 with extended mode - it fixes a lot of issues
from vue-promise-btn.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-promise-btn.