Narrating Prophetic Monks

    rx-dects
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.3 • Public • Published

    RxJS Decorators

    npm version Build Status

    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

    Installation and Usage

    To install this library, run:

    $ npm install rx-dects

    You can import library in any application:

      import { Observable, Observer } from 'rxjs';
      import { SharedObservable, CachedObservable } from 'rx-dects';
      
      @Injectable()
      export class DataService {
        public fetchSomeData(): Observable<any> {
          return this.generateObservable();
        }
      
        @SharedObservable()
        public fetchSharedData(): Observable<any> {
          return this.generateObservable();
        }
      
        @CachedObservable()
        public fetchCachedData(): Observable<any> {
          return this.generateObservable();
        }
      
        @SharedObservable()
        @CachedObservable()
        public fetchCachedAndSharedData(): Observable<any> {
          return this.generateObservable();
        }
      
        public generateObservable(): Observable<any> {
          return Observable.create((observer: Observer<string>) => {
            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

    Install

    npm i rx-dects

    DownloadsWeekly Downloads

    1

    Version

    0.1.3

    License

    MIT

    Unpacked Size

    5.77 kB

    Total Files

    8

    Last publish

    Collaborators

    • grachpower