https://github.com/grachpower/rx-dects
Typescript decorators for RxJS
https://github.com/grachpower/rx-dects
angular decorator decorators reactive-programming reactive-x rx rxjs typescript
Last synced: about 1 year ago
JSON representation
Typescript decorators for RxJS
- Host: GitHub
- URL: https://github.com/grachpower/rx-dects
- Owner: grachpower
- Created: 2019-01-19T19:26:47.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-21T19:47:42.000Z (about 7 years ago)
- Last Synced: 2024-04-25T22:02:47.045Z (almost 2 years ago)
- Topics: angular, decorator, decorators, reactive-programming, reactive-x, rx, rxjs, typescript
- Language: TypeScript
- Homepage:
- Size: 97.7 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RxJS Decorators
[](https://badge.fury.io/js/rx-dects)
[](https://travis-ci.com/grachpower/rx-dects)
Rx-dects is a library with with typescript decorators which can help you to work with RxJs Observables.
## Benefits
Declarative design to sharing and caching rxjs observables.
## Examples
- [Stackblitz Demo](https://stackblitz.com/edit/rs-dects-example)
## Installation and Usage
To install this library, run:
```bash
$ npm install rx-dects
```
You can import library in any application:
```typescript
import { Observable, Observer } from 'rxjs';
import { SharedObservable, CachedObservable } from 'rx-dects';
@Injectable()
export class DataService {
public fetchSomeData(): Observable {
return this.generateObservable();
}
@SharedObservable()
public fetchSharedData(): Observable {
return this.generateObservable();
}
@CachedObservable()
public fetchCachedData(): Observable {
return this.generateObservable();
}
@SharedObservable()
@CachedObservable()
public fetchCachedAndSharedData(): Observable {
return this.generateObservable();
}
public generateObservable(): Observable {
return Observable.create((observer: Observer) => {
setTimeout(() => {
observer.next(`Data: ${Math.random() * 100}`);
observer.complete();
}, 200);
});
}
}
```
## Important
Important to install RxJS version 6 and above
## Building/Testing
- `npm run build` - builds everything
- `npm test` - runs tests