Fork me on GitHub
#membrane
<
2022-01-16
>
Ben Sless09:01:26

Picking back up my experiments with membrane, here's where I left off

👀 1
Ben Sless09:01:43

Currently, loading the comments on a post is a long blocking operation. I was wondering how I could build it differently such that each comment was loaded asynchronously as an effect

Ben Sless09:01:51

If I have a vector of children, I need something like (update v idx load!) Will this be translated to (dispatch! :update v (fn [v] (assoc v idx (load! (v idx)))?

Ben Sless09:01:14

Then I'll need to emit some tree of effects and make sure they are applied correctly, too

Ben Sless09:01:34

any help orienting around this would be appreciated 🙏

phronmophobic20:01:40

:thumbsup: I'll write up some thoughts on strategies for lazy loading in bit

phronmophobic23:01:15

ok, here's my take

phronmophobic23:01:08

A major design goal of membrane is to avoid "how do I do X in membrane?" problems and turn them into "how do I do X?" problems. The main requirements for background loading are: 1. Don't run I/O on the main thread 2. Tell membrane to repaint when state is updated outside of the main dispatch thread. Other than that, you're basically free to use whatever libraries or techniques for background processing that you want. I used futures, but any library should work. There's no real coordination between updates in the example, but I think that should be ok for this use-case. For other apps, you might want to include better support for transactions and constraints. Hopefully, that's another case of "How do I do consistent updates?" problem rather than "How do I do consistent updates in membrane?" problem. The other major change was converting

(map story-item top)
to
(for [story-id top]
  (let [story (get entities story-id)]
    (if story
      (story-item {:story story})
      (ui/label "loading..."))))
defui understands for and will automatically wire state to elements in the for body. I'm sure there's a better way to integrate with functions like map, but I haven't prioritized it since there's an easy work around. That's the reason why the hover states weren't working for the stories and comments buttons.

phronmophobic23:01:43

I still consider membrane to be in the design phase and most development is based on trying to figure out what membrane should look like rather that just implementing features. The result is that membrane is missing many features users expect and it's hard to tell the difference between 1) feature is broken 2) feature is missing because it hasn't been implemented yet 3) feature is missing because the concept doesn't belong in membrane. So thanks for taking the time to try membrane! 😬 😁

Ben Sless09:01:08

Also, scrolling doesn't work :thinking_face:

phronmophobic19:01:29

I was looking into this first. facepalm I didn't implement the scrollview drawing for java2d, https://github.com/phronmophobic/membrane/blob/master/src/membrane/java2d.clj#L517. It works under skia though! Fixing java2d right now!

phronmophobic20:01:04

I also found that mouse scroll wheel events weren't implemented for java2d. Fixed.

Ben Sless21:01:31

Happy to be a useful lab rat 😄

🙏 1
gratitude 1