Fork me on GitHub

;; run the ui
  (fn []
    (with-effect-handler my-counter-effect-handler
      (counter-ui (my-counter-effect-handler [:get-count])))))
The app doesn't react to change at this point, right? counter-ui is initialized with a number and the count atom will increment when the button is clicked but the change wouldn't show up on the ui unless you re-run the app. The next section introduces references to solve the problem "that it doesn't say which counter should be incremented". Don't references also enable the app to be reactive without re-running the whole app? In the snippet above, with-effect-handler gets a ui element , counter-ui, that has already curried a number for the count. There's no way to change the count in counter-ui; you must construct a new counter-ui. Using a reference instead would allow the value to change as is epitomized in the quote: "By identity I mean a stable logical entity associated with a series of different values over time." If I have the right idea then I'd like to see the blog mention whether the pseudocode example is enough to give us an app that updates the count on button click or if that is currently missing and gained by using references. The gif shows the count update on button click which makes me think I just don't understand how it's currently reactive.


It should change at that point in the blog post


The function

(fn []
    (with-effect-handler my-counter-effect-handler
      (counter-ui (my-counter-effect-handler [:get-count]))))
Will be called to rerender the view whenever an event occurs


Yea, I just double checked.


It makes sense. I convinced myself that there must be more to it since it would need to re-build the ui for every change; I assumed that there was a reason that wasn't doable. Performance or something idk; I was hand waving... Thanks.


defui does some caching, but you can get pretty far rebuilding the UI on every change.


You do eventually want some sort of caching just so you're not wasting CPU or run into issues as your app gets bigger, but building a view is usually pretty fast


If I recall correctly, even React usually rebuilds the full vdom on every change unless you override stuff like componentDidUpdate


Thanks. I'm re-reading the third blog post since I couldn't take it all in the first time. I just finished the first five chapters of fulcro's developer guide. I like the co-located query and initial state. I can imagine how that makes for reusable components. I also really like that membrane components return the intents instead of effectfully dispatching in the :on-click, :on-changed thing.


Yea, I liked fulcro when I looked into it. I learned a lot when I gave it a try. I think the biggest differences between how membrane and fulcro are: • membrane components are pure functions • membrane components return values • I remember fulcro's story for dynamic queries was awkward. For example, implementing a tabbed pane component is tricky. • I remember it being awkward handling incidental component state and contextual state. For example, implementing a textarea where the cursor, text, selection, and focus state are incidental is tricky. It's been a while and I never became a fulcro expert, so ymmv.


I'm wondering why the effectful way is ubiquitous; is it a concern that you can't return the value? e.g. :on-change #(swap! assoc :thing (.. % -target -value)) If I try to return the thing, the real value might go out of scope since it's interop with the browser... Wait no, it's the same as swapping it into a db. Never mind. I guess it's just easy... Do any other framework return the "I'm clicked" events?


I think the number one reason most frameworks use effectful events is that the general approach is trying to layer functional code on top of OO code.


Basically, they try to bolt on functional approach on top of HTML,Swing,GTK, etc


Before talking about it today, I thought the java2d backend was using java2d stuff. I see now that it's all in graphics2d. That makes sense.


Sorry, what I said doesn't make any sense. I assumed that the java2d backend was using awt stuff. Like a java Button component for a button. I see now that it's just rectangles and text.

👍 1