Hello again! Thanks in advance for the comments and help- the forum has been good to me so far!
I have the following bindings to a JS function that takes an object as parameters, like this: foo({ one, two }). I would like to expose labeled arguments to my ReScript code but have them translated as an object in the bindings. Here’s what I have in my bindings:
Going to give this a shot, thanks for the link! What’s the current idiomatic approach? Should I just do an object and not worry about labeled arguments?
Well, currently, it’s easy to bind in such a way that you end up writing foo(fooOptions(~one, ~two, ())), which I think is not too bad, just a bit verbose. That’s what my cookbook example shows.
I also use the foo(fooOptions()) pattern but I sometimes prefer it based on @deriving(abstract), rather than @obj. They do very similar things when used for this purpose, deriving can be a bit unwieldy when every field is optional but it does have the advantage of looking a bit more like the JS code.
It’s definitely nice. Be careful with the bindings shadowing though, in case you have some normalParam, recursive and other things that share the same name in the scope. Happens more often that you’d think, especially if you have multiple of these @deriving(abstract)