Drewverlee
09/22/2020, 1:04 PM[:what
[::global ::all-todos all-todos]
[::global ::showing showing]
:then
(let [*session (orum/prop)
active-todos (remove :done all-todos)
completed-todos (filter :done all-todos)
active (count active-todos)
completed (count completed-todos)
filter-attrs (fn [filter-kw]
{:class (when (= filter-kw showing) "selected")
:on-click #(insert! *session ::global {::showing filter-kw})})]
[:footer#footer
[:span#todo-count
[:strong active] " " (case active 1 "item" "items") " left"]
[:ul#filters
[:li [:a (filter-attrs :all) "All"]]
[:li [:a (filter-attrs :active) "Active"]]
[:li [:a (filter-attrs :completed) "Completed"]]]
(when (pos? completed)
[:button#clear-completed {:on-click #(run! (partial retract! *session)
(map :id completed-todos))}
"Clear completed"])])]
Nick Smith
09/23/2020, 3:53 AMDrewverlee
09/23/2020, 1:00 PMUsing a rule engine allows us to know exactly what changes from one state to the next. This means we don't need React's diff algorithm or the concept of subscriptions. If we declare views as the consequences of rules, we can automatically point update them when the facts they care about change.And richer discussion on reddit https://www.reddit.com/r/Clojure/comments/bqh0z4/virtual_dom_is_pure_overhead/eo4gyuj?utm_source=share&utm_medium=web2x&context=3
So it would seem a RETE network would be one way to achieve this?But the question i would ask is, if your only concern is what is achievable via programming, then why discuss logic programming at all? Logic programming offers nothing new in terms of end results. What it offers is a mental model and decades of research in algorithms on how to fit problems into it. Given all that, I would still use a none logic based front end framework/library today. Why? because the ecosystem built around them isn't as rich. I'm worried that's because little to no discussion is generated around merging these two fields. The browser application ecosystem is ripe with places where applications of decades old algorithms and models could have huge impacts on peoples lives today. The future of programming is going to read more like math from a decade ago, we don't need to discover it, its already there, we need to apply it.