mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-04-19 14:52:34 +00:00
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { Component, OnDestroy, OnInit } from '@angular/core';
|
|
import { Subject } from 'rxjs';
|
|
import { takeUntil } from 'rxjs/operators';
|
|
|
|
import { InvoiceService } from 'app/main/pages/invoices/invoice.service';
|
|
|
|
@Component({
|
|
selector : 'invoice-compact',
|
|
templateUrl: './compact.component.html',
|
|
styleUrls : ['./compact.component.scss']
|
|
})
|
|
export class InvoiceCompactComponent implements OnInit, OnDestroy
|
|
{
|
|
invoice: any;
|
|
|
|
// Private
|
|
private _unsubscribeAll: Subject<any>;
|
|
|
|
constructor(
|
|
private _invoiceService: InvoiceService
|
|
)
|
|
{
|
|
// Set the private defaults
|
|
this._unsubscribeAll = new Subject();
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------------------------------
|
|
// @ Lifecycle hooks
|
|
// -----------------------------------------------------------------------------------------------------
|
|
|
|
/**
|
|
* On init
|
|
*/
|
|
ngOnInit(): void
|
|
{
|
|
this._invoiceService.invoiceOnChanged
|
|
.pipe(takeUntil(this._unsubscribeAll))
|
|
.subscribe((invoice) => {
|
|
this.invoice = invoice;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* On destroy
|
|
*/
|
|
ngOnDestroy(): void
|
|
{
|
|
// Unsubscribe from all subscriptions
|
|
this._unsubscribeAll.next();
|
|
this._unsubscribeAll.complete();
|
|
}
|
|
}
|