Giter Site home page Giter Site logo

re-frame-debounce-fx's Introduction

GitHub license

This library (and frankly this README too) was shamelessly cribbed from the re-frame-http-fx library.

Debounce Effects Handler for re-frame

This re-frame library contains a debounce Effect Handler.

Quick Start Guide

Step 1. Add Dependency

Add the following project dependency:
Clojars Project

Requires re-frame >= 0.8.0

Step 2. Registration And Use

In the namespace where you register your event handlers, perhaps called events.cljs, you have 2 things to do.

First, add this "require" to the ns:

(ns app.core
  (:require
    ...
    [johnswanson.re-frame.debounce-fx]   ;; <-- add this
    ...))

Because we never subsequently use this require, it appears redundant. But its existence will cause the :dispatch-debounce effect handler to self-register with re-frame, which is important to everything that follows.

Second, write a an event handler which uses this effect:

(reg-event-fx                           ;; note the trailing -fx
  :handler-with-debounce                ;; usage:  (dispatch [:handler-with-debounce])
  (fn [fx [_ value]]                    ;; the first param will be "world"
    {:dispatch-debounce {:key :search
                         :event [:search value]
                         :delay 250}}))

Look at the :handler-with-debounce line above. This library defines the "effects handler" which implements :handler-with-debounce.

The supplied value is a simple options map with three required keys: :key, :event, and :delay.

When the effect fires, we will wait for :delay ms. At that point, we'll check to see whether another :handler-with-debounce effect has fired with the same :key since our effect was fired.

  • If not, we will dispatch our event.
  • If another event fired, we will do nothing (another event is now pending)

re-frame-debounce-fx's People

Contributors

johnswanson avatar

Stargazers

Benjamin avatar  avatar Anton Chebotaev avatar Jameel avatar

Watchers

 avatar

Forkers

the-frey

re-frame-debounce-fx's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.