id | keywords | name | summary | category | ||
---|---|---|---|---|---|---|
meth-decorator |
|
@meth |
This is the `@meth` decorator. |
decorators |
The @meth
decorator is used to call a function on a JavaScript object,
and avoid issues with currying.
Suppose we have the following JavaScript:
function say (a, b) {
console.log(a, b);
};
var john = {
say
};
We can model and bind to this object as follows.
<CodeTab labels={["ReScript", "JS Output"]}>
type person = {@meth "say": (string, string) => unit}
@val external john: person = "john"
john["say"]("hey", "jude")
john.say("hey", "jude");