ngx-async
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

ngx-async

Bind observable to class property. Unlike async pipe it works in component.

Demo

Live example on stackblitz

Install

npm install ngx-async

Usage

component.ts

import { Component, OnDestroy } from '@angular/core';
 
import { interval } from 'rxjs';
import { map } from 'rxjs/operators';
 
import { Async } from 'ngx-async';
 
@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnDestroy {
  @Async currentTime = interval(1000).pipe(
    map(() => Date.now()),
  );
 
  ngOnDestroy() {
    // assign null for unsubscribe
    this.currentTime = null;
  }
}

component.html

   <p>Now {{ currentTime | date:'HH:mm:ss' }}</p>

Package Sidebar

Install

npm i ngx-async

Weekly Downloads

0

Version

1.0.7

License

MIT

Unpacked Size

7.24 kB

Total Files

15

Last publish

Collaborators

  • bobrovskih