Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0be5313

Browse files
author
Kevan Stannard
committedJan 9, 2021
Update send decorator
1 parent c764884 commit 0be5313

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed
 

‎misc_docs/syntax/decorator_send.mdx

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,26 @@ summary: "This is the `@send` decorator."
66
category: "decorators"
77
---
88

9-
The `@send` decorator is used to call a function on an object.
9+
The `@send` decorator is used to bind to a method on an object.
1010

11-
For example:
11+
### Example
1212

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

1515
```res
16-
type element
16+
type document
17+
@bs.send external getElementById: (document, string) => Dom.element = "getElementById"
18+
@bs.val external doc: document = "document"
1719
18-
@scope("document") @val
19-
external createElement: string => element = "createElement"
20-
21-
@send
22-
external appendChild: (element, element) => element = "appendChild"
23-
24-
let div = createElement("div")
25-
let button = createElement("button")
26-
27-
let _ = appendChild(div, button)
20+
let el = getElementById(doc, "myId")
2821
```
2922

3023
```js
31-
var div = document.createElement("div");
32-
33-
var button = document.createElement("button");
34-
35-
div.appendChild(button);
24+
var el = document.getElementById("myId");
3625
```
3726

3827
</CodeTab>
3928

29+
### References
4030

31+
* [Bind to JS Function](/docs/manual/latest/bind-to-js-function)

0 commit comments

Comments
 (0)
Please sign in to comment.