It seems add-watch isn't lite-mode compatible since it uses doseq - could this be fixed? I'm trying to keep Reagami lite-mode compatible, but people probably would want to use add-watch to re-render stuff on atom change
Not sure if it's important enough but it seems using (atom ..) in an app pulls in chunked-seqs via doseq. I tried making reagami CLJS-lite compatible but using an atom + add-watch is essential to its UX
Yeah atom is a bit annoying but the implementation was a bit too tangled up to want to deal with, I think volatile is better?
volatile! doesn't have add-watch :-(
on Atom I think doseq could be replaced with run! or so
but not sure if that solves all the issues
I doubt it, I looked at this a bit but my conclusion if you want atom you have to be ok w/ what that implies.
ok I guess people can write their own cljs-lite atom then
yeah I think that's reasonable, changing implementation details to accommodate light mode is not that awesome. Aside from pretty low level details of printing - this was avoided.
yeah, we have IAtom, ISwap etc anyway
Here's an example - it's a bit lighter than regular Atom https://github.com/kimo-k/core-lite/blob/cdc9e4649353b38bae12c8193b5b361c4c84db43/src/core/lite.cljc#L118
add-watch
cljs-core |||||||||||||||||||||||||||||||||||||||||||||||||| 8405 bytes (brotli)
core-lite |||||||||||||||||||||||||||||||||||||||||| 7209 bytes (brotli)
swap!
cljs-core |||||||||||||||||||||||||||||||||||||||||||||||||| 4757 bytes (brotli)
core-lite |||||||||||||||||||||||||||||||||||||||||| 4060 bytes (brotli)It gets much lighter if you store watches in a js/Map: https://github.com/kimo-k/core-lite/blob/8aef307a92e1be2f74efedbfd96b6e3e5daafb38/src/core/lite.cljc#L118
add-watch
cljs-core |||||||||||||||||||||||||||||||||||||||||||||||||| 8405 bytes (brotli)
core-lite ||||||||||||||||||||||| 3983 bytes (brotli)
swap!
cljs-core |||||||||||||||||||||||||||| 4757 bytes (brotli)
core-lite ||||||||||||||||||||| 3534 bytes (brotli)you're re-implementing squint ;)