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
- Host: GitHub
- URL: https://github.com/billcheng/auto-cancel-observable
- Owner: billcheng
- Created: 2019-10-04T23:42:06.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-19T23:44:50.000Z (almost 6 years ago)
- Last Synced: 2025-01-06T22:35:22.415Z (9 months ago)
- Topics: cancellation, observable, rxjs, subscription, typescript
- Language: TypeScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
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}¶m2=${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.