An open API service indexing awesome lists of open source software.

https://github.com/billcheng/auto-cancel-observable

Bind Observable to a unique name... new binding will cancel the previous binding/subscription automatically
https://github.com/billcheng/auto-cancel-observable

cancellation observable rxjs subscription typescript

Last synced: 8 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# Auto Cancel Observable
Automatically cancel subscription

# Install
```bash
npm i auto-cancel-observable
```
or
```bash
yarn auto-cancel-observable
```

# Example
```typescript
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.