I'm trying to wrap a Javascript library where I have a method A.bar(f) which takes as parameter a function f : B -> void.
Since I'd like to use bar to perform some anynchronous computations, on the Purescript side, I have a function declaration
foreign import foo :: Fn2 A (B -> Aff Unit) -> EffectFnAff Unit
In its corresponding Javascript file, I have something like
exports.foo = function (a, f) {
return function (onError, onSuccess) {
a.bar(function (b) {
f(b)
})
return function (cancelError, cancelerError, cancelerSuccess) {
cancelerSuccess()
}
}
}
The issue I have is that f(b) is an Aff object and I don't know how to execute it on the Javascript side.