An effect to throttle Re-frame event dispatching. For the differences between debouncing and throttling, see this handy visualisation.
Add dependency to your project. See Clojars for details.
Require the namespace:
(ns app.core
(:require
...
[re-frame-throttle.core]
...))
(rf/reg-event-fx :foo/throttled-bar
(fn [_]
{:throttle-dispatch
{:event [:bar "baz"]
:ms 300 ; Defaults to 500 ms.
:id :foo/bar}}))
:throttle-dispatch
has three keys, two of which are required:
:event
is a required key. The value is dispatched in a throttled manner.:id
is a required key. The value is used to determine which events are
throttled together. Events sharing the same id are throttled together.:ms
is an optional key. The value is the amount of milliseconds waited
between dispatching the latest value of :event
. If the key is not
specified, the amount defaults to 500 ms.Copyright © 2021 Matias Salohonka
This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.
Can you improve this documentation?Edit on GitLab
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close