-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add multi argument callback helpers #76
Comments
Not sure if we need the type CallbackMulti = Callback ([JSVal] -> IO ())
syncCallbackMulti :: OnBlocked -> ([JSVal] -> IO ())
-> IO (Callback (JSVal -> IO ()), CallbackMulti)
syncCallbackMulti onBlocked f = do
callback <- syncCallback1 onBlocked $ \args ->
Array.toListIO (coerce args) >>= f
(callback,) <$> makeMultiArgCallback callback
foreign import javascript unsafe "$r = function () { $1(arguments); }"
makeMultiArgCallback :: Callback (JSVal -> IO ()) -> IO CallbackMulti |
I suggest documenting |
Is a polyvariadic function going to help here? I don't know much about polyvariadic functions. |
@luite This is useful because http://electron.atom.io/docs/api/app/#event-certificate-error requires a callback of 6 arguments. Currently, ghcjs-base cannot handle |
We should add something like this to
GHCJS.Foreign.Callback
(based onfunction
from jsaddle):Returns two values. The first is just for use with
releaseCallback
, the second is to pass on to JavaScript. We should change it to something more meaningful thanObject
.The text was updated successfully, but these errors were encountered: