File tree 1 file changed +35
-0
lines changed
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ id : " obj-decorator"
3
+ keywords : ["obj", "decorator"]
4
+ name : " @obj"
5
+ summary : " This is the `@obj` decorator."
6
+ category : " decorators"
7
+ ---
8
+
9
+ The ` @obj ` decorator is used to create functions that return JavaScript objects
10
+ with properties that match the function's parameter labels.
11
+
12
+ ### Example
13
+
14
+ <CodeTab labels = { [" ReScript" , " JS Output" ]} >
15
+
16
+ ``` res
17
+ @bs.obj
18
+ external action: (~name: string, unit) => _ = ""
19
+
20
+ let helloAction = action(~name="Hello")
21
+ ```
22
+
23
+ ``` js
24
+ function helloAction (param ) {
25
+ return {
26
+ name: " Hello" ,
27
+ }
28
+ }
29
+ ```
30
+
31
+ </CodeTab >
32
+
33
+ ### References
34
+
35
+ * [ Convert External into JS Object Creation Function] ( /docs/manual/latest/generate-converters-accessors#convert-external-into-js-object-creation-function )
You can’t perform that action at this time.
0 commit comments