Skip to content

Dynamic documents and lost updates #36

@dariusf

Description

@dariusf

Hi, I was trying out the Brr backend and had a couple of questions.

let ui =
  let count = Lwd.var 0 in
  let on_click () = Lwd.set count (Lwd.peek count + 1) in
  let button =
    Lwd.map
      ~f:(fun i ->
        let btn = El.button [El.txt' (string_of_int i)] in
        Ev.listen Ev.click (fun _e -> on_click ()) (El.as_target btn);
        btn)
      (Lwd.get count)
  in
  Elwd.div [`R button]

The rest of the file is the same as in the Brr example. If I replace the last line with button, the button no longer updates.

  1. I'm guessing this is due to the mismatch between the pure interface and the statefulness of the DOM. Should we always ensure that the top-level node is not dynamic, or is there a better workaround? Maybe this could be documented somewhere.
  2. Is this what the commented line is meant to address?

Anyway, I really like Lwd so far, awesome work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions