This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-26
Channels
- # announcements (17)
- # babashka (68)
- # beginners (8)
- # biff (14)
- # calva (25)
- # cherry (10)
- # clj-kondo (1)
- # clj-on-windows (12)
- # cljsrn (6)
- # clojure (134)
- # clojure-berlin (1)
- # clojure-europe (33)
- # clojure-nl (4)
- # clojure-norway (6)
- # clojure-uk (10)
- # clojurescript (9)
- # datalevin (8)
- # datomic (34)
- # docker (1)
- # emacs (31)
- # fulcro (6)
- # honeysql (8)
- # java (7)
- # joyride (14)
- # kaocha (7)
- # malli (11)
- # nbb (4)
- # off-topic (11)
- # pedestal (14)
- # rdf (53)
- # re-frame (6)
- # reagent (39)
- # reitit (2)
- # releases (9)
- # rewrite-clj (14)
- # shadow-cljs (97)
- # specter (1)
- # testing (5)
- # tools-deps (12)
- # vim (4)
- # xtdb (9)
Implementing a debounce util where a function returns a function that resets a timer before firing. The timer id variable typically changes over time. I know an atom could work but is there a better tool for that job?
I'd use an atom, yes. Unless the debouncing for some reason is in a hot spot, then a regular field on some JS object, probably on the function itself.
@U8WFYMFRU I mean typically you would use lodash.debounce
I would think
unless there’s some reason not to
It's a really small function to implement, lodash's implementation is gigantic and not needed for my use case. https://github.com/lodash/lodash/blob/master/debounce.js vs:
(defn debounce
[ms f]
(let [timer-atom (r/atom -1)]
(fn [& args]
(js/clearTimeout @timer-atom)
(reset! timer-atom (js/setTimeout #(apply f args) ms)))))
I am hoping to capture a failing test name in test code and then run some code based off the test name. Is the best way to do this a custom test reporter that runs against the :fail
event? Would I need to define a new multimethod to achieve this?
(defmulti custom-reporter
(fn [m] [::custom-reporter (:type m)]))
(defmethod custom-reporter [::custom-reporter :fail]
(fn [m] (reset! failed-test (:name m))
• Is there an easier way to capture a failing test name in test code?
• How do I specify that the test runner use the custom reporter?
• If I wanted the [::custom-reporter :fail]
method to additionally call the default :fail
implementation (the default logging on failed tests is useful), is there a way to do that?