There seems to be a regression, or the docs are wrong, regarding the signature of an effect-function.
When attempting to use the third parameter sent to an effect-function (documented as "error" -- a function you may call if something goes wrong), there console says:
Uncaught TypeError: error is not a function
(... assuming error is the name I gave the third parameter)
Demo: http://codepen.io/anon/pen/VPEYjj (forked from the effects-demo)
It comes from the docs. Third argument is data, fourth is the onError hook. app.js#L75
offtopic: I hate codepan.. how can i see the mentioned error? console shows nothing.
Never like it, never will - design, feel and all.
Yeah the only way to see the error in my codepen example is to open upp the browser dev-tools. The code-pen console seems oblivious to anything but "console.log(...)"
I used code-pen just so I could provide a working example of the bug, but I'm happy to use any other tool you may suggest.
Thanks for pointing out that the docs are out of date!
@tunnckoCore jsbin is great for actual debugging 馃槃
But CodePen is nice to share things with. The console is weird is CodePen as well haha
Thanks for pointing out that the docs are out of date!
@zaceno thanks, we didn't notice that.
@zaceno Thanks for reporting, gonna fix those doc-doc-docs!
Correct signature should be:
waitThenAdd: (model, msg, data, error)
For the record, if you update the pen as follows, here's what happens.
const effects = {
waitThenAdd: (model, msg, data, error) => {
console.log(data) // => HTML event since onclick=${msg.waitThenAdd}
msg.toggle()
wait(1000)
.then(msg.add)
.then(msg.toggle)
.then(() => {error('just a message')}) // => throws the error with the specified message
}
}
@zaceno Fixed, see https://github.com/hyperapp/hyperapp#effects
Let me know if that looks good to you. I think we're done here, so I'll close, but feel free to reopen if you feel this is still incomplete.
/cc @tunnckoCore
Doc's are fine now, as far as I'm concerned at the moment anyway :) Nice swift work!