Skip to content

Bind Observable to a unique name... new binding will cancel the previous binding/subscription automatically

Notifications You must be signed in to change notification settings

billcheng/auto-cancel-observable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auto Cancel Observable

Automatically cancel subscription

Install

npm i auto-cancel-observable

or

yarn auto-cancel-observable

Example

import { AutoCancelObservable } from 'auto-cancel-observable'

@AutoCancelObservable()
methodName(param1, param2) {
    return this.http.get(`${url}?param1=${param1}&param2=${param2}`)
}

...

this.methodName('X','Y')
    .subscribe(data => ...) // do something with the data

Invoking methodName multiple times will cancel the previous http calls and only the last or latest http data will be streamed to the subscription.

About

Bind Observable to a unique name... new binding will cancel the previous binding/subscription automatically

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published