Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 805 Bytes

decorator_send.mdx

File metadata and controls

38 lines (27 loc) · 805 Bytes
id keywords name summary category
send-decorator
send
decorator
@send
This is the `@send` decorator.
decorators

The @send decorator is used to bind to a method on an object or array.

Example

<CodeTab labels={["ReScript", "JS Output"]}>

// Bind to a method on an object
type document
@send external getElementById: (document, string) => Dom.element = "getElementById"
@val external doc: document = "document"
let el = getElementById(doc, "myId")

// Bind to a method on an array
@send external fillInPlace: (array<'a>, 'a) => array<'a> = "fill"
let a = fillInPlace([1, 2, 3], 99)
var el = document.getElementById("myId");

var a = [1, 2, 3].fill(99);

References