While learning ReasonML and bs-webapi, I had a hard time understanding how to use a function in the bs-webapi library. Since there is no documentation, I thought I could look at the code, but here I found something confusing.
Example:
Webapi.Dom.EventTarget.addEventListener(
"click",
someClickHandler,
Webapi.Dom.Element.asEventTarget(element)
)
This takes three parameters, but looking at the library function
[@bs.send.pipe : T.t] external addEventListener : (string, Dom.event => unit) => unit = "";
I can only see two parameters.
I understand that in JavaScript the object is bound like a method, i.e. target.addEventListener(), and in ReasonML it’s part of the parameters, i.e. addEventListener(…, …, target), but where does this happen and how will I understand this from just reading the code?