8.0.0 • Published 1 year ago

ngx-observe v8.0.0

Weekly downloads
77
License
MIT
Repository
github
Last release
1 year ago

npm-badge   travis-badge   codecov-badge

ngx-observe is an Angular structural directive with first-class support for observables.

🧩 designated loading & error templates ⚠️ access to errors ✅ support for falsy values 🚀 OnPush ready

Example StackBlitz

You can find an in-depth explanation here.

Installation

npm i ngx-observe

Usage

Import NgxObserveModule:

import { NgxObserveModule } from 'ngx-observe';

@NgModule({
  imports: [
    ...
    NgxObserveModule 
  ],
  ...
})
export class AppModule { }

Bind observable with Angular microsyntax. You might also then configure your component to use OnPush-ChangeDetection.

@Component({
  ...
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class AppComponent  {
  users$: Observable<User>

  constructor(private http: HttpClient) {}

  ngOnInit() {
    this.users$ = this.http.get<User[]>('/users')
  }
}
<p *ngxObserve="users$ as users; before loadingTemplate; error errorTemplate">
  There are {{ users.length }} online.
</p>
<ng-template #loadingTemplate>
  <p>Loading ...</p>
</ng-template>
<ng-template #errorTemplate let-error>
  <p>{{ error }}</p>
</ng-template>
InputTypeDescription
ngxObserveObservable<T>Observable to display
ngxObserveBeforeTemplateRef<undefined>Template to display before observable emits first value
ngxObserveErrorTemplateRef<ErrorContext>Template to display when observable errors
ngxObserveNextTemplateRef<ObserveContext>Template to display for emitted values
8.0.0

1 year ago

7.0.0

1 year ago

5.0.0

2 years ago

6.0.0

2 years ago

4.0.0

3 years ago

3.0.0

4 years ago

2.0.0

4 years ago

1.1.1

4 years ago

1.1.1-context.0

4 years ago

1.1.0

5 years ago

1.1.0-0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.2

5 years ago