My question is how do I signature external function to return a promise like code above. Currently, I used unit type but compiler always complain about usage of Js.Promise.then_.
You need to define the _ placeholder on the last position of Js.Promise.then_, since it’s still a pipe-last API (subject to change soon). To fix your bug you need to do this:
let main = {
init({
liffId: "ab2d",
})->Js.Promise.then_(_ => Js.Promise.resolve(), _)
}
Note the very last _ in the then_ call. This is equivalent to this:
let main = {
let p = init({
liffId: "ab2d",
})
Js.Promise.then_(_ => Js.Promise.resolve(), p)
}
Easiest would be to look at the type-signature, e.g. here it takes a function as the first argument, while the last argument is the Js.Promise.t('a). So you’d use it like: