Using Rescript with Preact?

You could indeed use either a mutable field or a @set binding to create a setter function, just use whatever feels the more natural!

1 Like

I 100% prefer to write my own bindings. I also feel like it helps me understand the source library better, and I get to come up with a solution that matches how I want to use it.

Here’s what I have for signal bindings: rescript-fresh/bindings/Signal.res at main · jderochervlk/rescript-fresh · GitHub

1 Like

Totally fair! I got the mutable version working, but figured it wouldn’t hurt to have a get and set function to play nicely with the chaining → operator.

I did get those working with:

@set external set: (t<'a>, 'a) => unit = "value"
@get external get: (t<'a>) => 'a = "value"
@send external peek: t<'a> => 'a = "peek"
3 Likes