LexiFi / ocaml-vdom

Elm architecture and (V)DOM for OCaml
MIT License
197 stars 13 forks source link

memo requires function equality #13

Closed copy closed 6 years ago

copy commented 6 years ago

There's one edge-case of Vdom.memo that should be documented: It checks for physical equality (Javascript's ===) of the callback, so it doesn't work if the callback is written inline (i.e. memo (fun …)). Took me some time to figure out.

alainfrisch commented 6 years ago

The documentations already mentions that physical equality is used:

(** Apply the function to generate a VDOM tree only if the function
    or its argument have changed (physically) from the previous
    synchronization.

Do you think some extra explanation would be useful?

copy commented 6 years ago

Do you think some extra explanation would be useful?

Yes, I believe it would be useful to mention that physical equality fails for inline functions.

alainfrisch commented 6 years ago

https://github.com/LexiFi/ocaml-vdom/commit/b76d7d2430fb5dad4647206c435520e82089dbaf

Let me know if you have something better!

copy commented 6 years ago

Let me know if you have something better!

Sounds clear to me, thanks!