id | keywords | name | summary | category | ||
---|---|---|---|---|---|---|
send-decorator |
|
@send |
This is the `@send` decorator. |
decorators |
The @send
decorator is used to bind to a method on an object or array.
<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);