This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-14
Channels
- # adventofcode (38)
- # announcements (42)
- # aws (3)
- # babashka (8)
- # beginners (165)
- # calva (36)
- # chlorine-clover (14)
- # cider (6)
- # clj-kondo (5)
- # cljsrn (33)
- # clojure (27)
- # clojure-australia (1)
- # clojure-czech (1)
- # clojure-doc (1)
- # clojure-europe (26)
- # clojure-nl (6)
- # clojure-spec (6)
- # clojure-uk (3)
- # clojurescript (10)
- # code-reviews (20)
- # conjure (1)
- # core-logic (5)
- # cursive (3)
- # data-science (5)
- # datomic (35)
- # emacs (1)
- # figwheel-main (3)
- # fulcro (10)
- # honeysql (1)
- # introduce-yourself (4)
- # jobs (3)
- # jobs-discuss (4)
- # minecraft (2)
- # missionary (28)
- # nextjournal (3)
- # off-topic (45)
- # pathom (7)
- # polylith (1)
- # portal (22)
- # practicalli (2)
- # re-frame (4)
- # reagent (19)
- # releases (3)
- # remote-jobs (3)
- # reveal (1)
- # rum (4)
- # shadow-cljs (37)
- # spacemacs (14)
- # sql (1)
- # tools-build (7)
- # tools-deps (16)
- # vim (13)
- # xtdb (15)
random q: given a flow, how do I take values in a throttled way? (i.e. take value, ignore all values for 500ms, wait for next value)
there's an example for debounce
which is conceptually similar enough that it might be helpful to you https://github.com/leonoel/missionary/blob/8c34d5e11e11960f905cddec88fb49cd9b2ecfa0/src/missionary/core.cljc#L193-L211 (but I've never used missionary so perhaps it's not helpful at all)
I found this explanation helpful when I was thinking about throttling & debouncing a few months back https://css-tricks.com/debouncing-throttling-explained-examples/
you can sample a continuous flow once every 500 ms (pulling a lazy value through every 500 ms based on a clock stream), is that what you want? https://cljdoc.org/d/missionary/missionary/b.24/api/missionary.core#sample
events are eager/push, signals are lazy sampled, so i think here the idea of throttling implies signal
Note that event streams are backpressured so they are self-throttling, which is different than controlling the throttling with a userland clock
I have created a new page https://github.com/leonoel/missionary/wiki/Debounce-and-Throttle
@U09K620SG thanks for that explanation, you’re making some interesting distinctions with terminology that made me understand the problem better!
@leonoel that page is awesome, thank you very much!
(If you eventually want to incorporate those docs into cljdoc you might need to put them into the repo)
@U050TNB9F is there a way to import a separate doc repo in cljdoc ? The wiki has different write permissions and I'd like to keep it as the single source of truth
There isn’t currently. You might be able to get it to work with embedding the wiki as a submodule but I haven’t really played around with that. Overall I like the fact that putting documentation inside the repo 1. recognizes contributors to documentation more 2. is versioned alongside the code But I agree, the contribution process to a wiki is a bit more straightforward.
searching the API docs for “throttle” didn’t yield anything
you can sample a continuous flow once every 500 ms (pulling a lazy value through every 500 ms based on a clock stream), is that what you want? https://cljdoc.org/d/missionary/missionary/b.24/api/missionary.core#sample
events are eager/push, signals are lazy sampled, so i think here the idea of throttling implies signal
Note that event streams are backpressured so they are self-throttling, which is different than controlling the throttling with a userland clock
Something Leo said in his talk which I'm not sure made sense to me is that returning thunks that will do IO is function all and pure. Is that correct? They still hide potential side effects, effects aren't reified in a fully pure manner
it's true - it means invokinng that thunk is unsafePerformIO
IO actions can be reified in several ways – thunks, symbolically using lisp quoting `(http! ~request) - both these things encode an effect as a value
I think where I'm iffy in thunks is that their resolution is at allocation time and not run time
Which means they're less testable. Unless you provide on top of that an effect handling system
testability meaning equality on IO Action instances? #() == #()
You know what, maybe I'm approaching this wrong. How should I go about testing code and systems written with missionary?
I should ask about the result I want and not the way I think I need to take to get there. It may be the wrong way
Testing is why ZIO bundles dependency injection, right?
I have created a new page https://github.com/leonoel/missionary/wiki/Debounce-and-Throttle
@leonoel if you feel like it, you can also show how to implement dropping/sliding buffer
this is equivalent to core.async
's dropping buffer :
(defn dropping-buffer [cap >in]
(->> >in
(m/relieve (fn [x _] x))
(m/buffer cap)))