This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-16
Channels
- # babashka (48)
- # beginners (44)
- # biff (3)
- # calva (1)
- # cider (42)
- # clj-kondo (8)
- # clojure (93)
- # clojure-australia (2)
- # clojure-europe (3)
- # clojure-taiwan (1)
- # clojurescript (10)
- # conjure (4)
- # deps-new (5)
- # joker (9)
- # lsp (12)
- # membrane (16)
- # minecraft (12)
- # missionary (4)
- # mount (3)
- # off-topic (60)
- # reitit (9)
- # releases (13)
- # ring-swagger (1)
- # shadow-cljs (18)
- # sql (67)
- # tools-deps (2)
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
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)))
?
Then I'll need to emit some tree of effects and make sure they are applied correctly, too
:thumbsup: I'll write up some thoughts on strategies for lazy loading in bit
ok, here's my take
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 future
s, 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.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! 😬 😁
I was looking into this first. 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!
Fixed! https://github.com/phronmophobic/membrane/commit/f63adf49beceae9976737c9aaefcf9c75583d9b0 I'll make a new release soon.
I also found that mouse scroll wheel events weren't implemented for java2d. Fixed.