reactiveData icon indicating copy to clipboard operation
reactiveData copied to clipboard

Rlist.from_signal can fail if the signal has no value

Open orbitz opened this issue 4 years ago • 0 comments

This is a noted aspect of React but it doesn't look like from_signal handles this correctly. Is there a known workaround? I run into this subtle error in code looking roughly like: div @@ Rlist.from_signal @@ React.S.map (..) some_signal.

I was thinking a simple workaround might be below?

  let from_signal ?(eq = (=)) s =
    let f d' d = Patch (D.diff ~eq d d') in
    from_event (try React.S.value s with Failure "signal value undefined yet" -> [] | _ -> assert false) (React.S.diff f s)

orbitz avatar Oct 27 '21 06:10 orbitz