Nothing Particularly Magnificent

    angular-request-dedup

    1.1.1 • Public • Published

    angular-request-dedup

    This library aims to deduplicate repetitive call to the server while the request is still pending and pass the same promise to callers.

    GitHub GitHub package.json version npm GitHub file size in bytes

    NPM

    When to use it

    Almost always.

    Say you have a button that calls the server then process the response and does something, but then the user -or any other scenario- clicked the button three times, that's three calls to server to do the same thing.

    Our service can provide caching the promise and dispatching the same promise to all three calls.

    How to use

    npm i angular-request-dedup

    Integrate in the angular app angular.module("app", ["angular-request-dedup"])

    Example

    class MainResource {
        constructor(AngularRequestDedup) {
            this.AngularRequestDedup = AngularRequestDedup;
        }
    
        getAll(params) {
            return this.AngularRequestDedup.dedup(url).get(params)
        }
    }
    

    Highlights

    1. Once the promise is resolved, the promise is discarded from the cache.
    2. You can pass isPersistent flag in the params object to keep the promise in the app state.

    Prerequisites

    • It works with minium of AngualrJs 1.5.x
    • Any bundler would do, no need for special loaders

    Install

    npm i angular-request-dedup

    DownloadsWeekly Downloads

    3

    Version

    1.1.1

    License

    MIT

    Unpacked Size

    5.55 kB

    Total Files

    6

    Last publish

    Collaborators

    • andrew-lawendy