Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 1787

Using Rescript with Preact?

$
0
0

Thanks!

Last night I stumbled upon GitHub - ajaxsys/rescript-preact: Test rescript with preact which covered the changes I needed to make and has similar bindings to yours (maybe they borrowed it from you?)

Took a stab at creating the bindings for Signals, seems to be working but I haven’t used all APIs yet:

module Signal = {
  type t<'value> = {
    mutable value: 'value
  }

  @module("@preact/signals")
  external make: 'a => t<'a> = "signal"

  // @set external set: (t<'a>, 'a) => unit = "value"

  @module("@preact/signals")
  external effect: (@uncurry (unit => unit)) => (@uncurry unit => unit) = "effect"

  @module("@preact/signals")
  external computed: (@uncurry (unit => 'a)) => t<'a> = "computed"

  @module("@preact/signals")
  external batch: (@uncurry (unit => unit)) => 'any = "batch"

  @module("@preact/signals")
  external useSignal: 'a => t<'a> = "useSignal"

  @module("@preact/signals")
  external useComputed: (@uncurry (unit => 'a)) => t<'a> = "useComputed"
}

Trying to write a setter function but my ReScript is really rusty these days :sweat_smile:


Viewing all articles
Browse latest Browse all 1787

Trending Articles