This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-22
Channels
- # announcements (2)
- # aws (5)
- # babashka (17)
- # beginners (108)
- # calva (28)
- # chlorine-clover (7)
- # clj-kondo (14)
- # cljs-dev (9)
- # cljsrn (2)
- # clojure (118)
- # clojure-europe (50)
- # clojure-finland (5)
- # clojure-france (15)
- # clojure-italy (9)
- # clojure-nl (14)
- # clojure-spec (11)
- # clojure-uk (43)
- # clojuredesign-podcast (1)
- # clojurescript (35)
- # clojutre (2)
- # clr (3)
- # community-development (6)
- # conjure (9)
- # core-async (41)
- # cursive (7)
- # data-science (7)
- # datomic (11)
- # events (1)
- # figwheel-main (4)
- # fulcro (20)
- # ghostwheel (9)
- # graalvm (18)
- # helix (46)
- # leiningen (14)
- # observability (2)
- # off-topic (23)
- # pathom (4)
- # re-frame (5)
- # reitit (5)
- # rum (2)
- # shadow-cljs (32)
- # spacemacs (8)
- # specter (5)
- # sql (36)
- # timbre (3)
- # vim (15)
- # xtdb (2)
- # yada (2)
One thing I’ve always struggled with is how to model clojurescript UI DOM components (ie an arbitrary DOM tree) using core async. And I tend to come back to attempting this every few months :)
How do I expose from a UI component the need to trigger dom events on internal elements, and the output of events triggered on internal elements?
It seems like the options are
Have a general input and output chan for each ui component. Could either wrap the events and triggers in a way that meets my needs (IE [::focus]
could trigger the dom .focus
event on an internal element. And something like [::query-input “query string”] could be put on the output chan. One problem with this is the the events sometimes in theory represent separate async processes (ie a mouseover event could occur simultaneously as a click event), but it’s more rare for this to be relevant.
Have a specific input/output chan for each needed event type. Ie have the component have a :query-input-chan
which outputs changes to the internal query input element. Expose as many chans that are needed for each component.
I’m working on an emacs-like editor thing where there are windows and buffers in a windowing system where the buffers can be basically anything (ie a text editor, file picker, repl, etc). Each buffer is sort of it’s own entities and has its own lifecycle, dependencies and sub-processes. I haven’t found this to fit will with the reframe global message bus style, but I haven’t been satisfied with my attempts at either of the above approaches in isolated components either.
Any general tips/tricks or thoughts about this type of thing?
hi all, im struggling trying to understand how to apply a stateful transducer to a core.async channel
specifically, im interested in using this lib: https://github.com/MastodonC/kixi.stats
transducers on channels do run a completion step, but the result of the completion step is ignored
you may want something like async/transduce (a transducer over a channel) instead of a transducer passed to a channel
@hiredman My first attempt looks like this
(async/transduce :duration kixi/summary ch)
(transduce identity kixi.stats.core/summary [1 2 3])
=> {:min 1.0, :q1 1.25, :median 2.0, :q3 2.75, :max 3.0, :iqr 1.5}
1:1 you transduce just requires an initial value, which you might be able to get by calling summary with 0 arguments
(transduce (map :duration) kixi.stats.core/summary [{:duration 1.0} {:duration 2.0} {:duration 3.0}])
=> {:min 1.0, :q1 1.25, :median 2.0, :q3 2.75, :max 3.0, :iqr 1.5}
clojure.core/transduce
([xform f coll] [xform f init coll])
reduce with a transformation of f (xf). If init is not
supplied, (f) will be called to produce it. f should be a reducing
step function that accepts both 1 and 2 arguments, if it accepts
only 2 you can add the arity-1 with 'completing'. Returns the result
of applying (the transformed) xf to init and the first item in coll,
then applying xf to that result and the 2nd item, etc. If coll
contains no items, returns init and f is not called. Note that
certain transforms may inject or skip items.