Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    chokepublic

    choke

    Function call throttling with hook for cancelling

    browser support

    Example

    var choke = require("choke")
    var EventSource = require("eventsource-reconnect")
    var setInterval = require("timers").setInterval
     
    var source = new EventSource("http://localhost:1234/events")
    var reconnect = choke(source.reconnect, 15000)
     
    source.onopen = reconnect.cancel    // kill any outstanding reconnect attempts 
     
    setInterval(function (){
        if (source.readyState === source.CLOSED) {
            source.onclose = reconnect.listener // throttle reconnects to 15 secs 
        }
    }, 1000)

    Installation

    npm install choke

    Contributors

    • Matt-Esch

    MIT Licenced

    Keywords

    none

    install

    npm i choke

    Downloadslast 7 days

    5

    version

    0.1.2

    license

    none

    repository

    github.com

    last publish

    collaborators

    • avatar