Skip to content

Latest commit

 

History

History
45 lines (30 loc) · 661 Bytes

decorator_meth.mdx

File metadata and controls

45 lines (30 loc) · 661 Bytes
id keywords name summary category
meth-decorator
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.

Example

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");