Fork me on GitHub
#re-frame
<
2020-02-03
>
ShaneLester17:02:35

anyone see anything glaringly wrong with this? getting re-frame: no handler registered for effect: :dispatch-debounce . Ignoring.

(re-frame/reg-event-fx
  ::update-programs
  [re-frame/trim-v]
  (fn [cofx [id search-text]]
    (let [db (:db cofx)]
        {:dispatch-debounce {:key ::debounced-programs
                             :event [::query-programs search-text]
                             :delay 250}
         :db (assoc-in db [:selects id :text] search-text)
        })))

mikerod17:02:32

@shanelester55 looks like you haven’t registered the debouncing effect handler

ShaneLester17:02:54

Ah. ok. so my problem is at a higher level then

ShaneLester17:02:59

will look into that

mikerod17:02:50

:dispatch-debounce is not built into re-frame

ShaneLester17:02:41

Ah ok. thank you. I must have misread in a github thread, because I thought it was. My mistake 🙂

mikerod17:02:53

There is a project or 2 out there that do offer this sort of fx

mikerod17:02:04

however, you’ll have to look at them to see if they fit your needs

mikerod17:02:22

there is the built-in :dispatch-later that sometimes is what you need, other times it isn’t enough

mikerod17:02:50

I’ve so far written my own :dispatch-debounce fx handler since I wasn’t entirely happy with existing libs - but was inspired by their impl

mikerod17:02:55

things may have changed

mikerod17:02:38

https://github.com/johnswanson/re-frame-debounce-fx has been where I’ve drawn inspiration from - and perhaps it’s all you need.

ShaneLester17:02:51

ahh that may be what i need. thanks again!

isak17:02:00

For debounce, you can also just use the stuff that comes with closure: goog.async.Debouncer

👍 4
isak17:02:19

(i.e., debounce a function that does the dispatching)

borkdude19:02:50

there is also goog.functions/debounce if you need something simple

4