mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-02-25 11:23:31 +00:00
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
|
import { Injectable } from '@angular/core';
|
||
|
import { HttpClient } from '@angular/common/http';
|
||
|
import { BehaviorSubject, Observable } from 'rxjs';
|
||
|
import { tap } from 'rxjs/operators';
|
||
|
|
||
|
@Injectable({
|
||
|
providedIn: 'root'
|
||
|
})
|
||
|
export class ProjectService
|
||
|
{
|
||
|
private _data: BehaviorSubject<any> = new BehaviorSubject(null);
|
||
|
|
||
|
/**
|
||
|
* Constructor
|
||
|
*/
|
||
|
constructor(private _httpClient: HttpClient)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
// -----------------------------------------------------------------------------------------------------
|
||
|
// @ Accessors
|
||
|
// -----------------------------------------------------------------------------------------------------
|
||
|
|
||
|
/**
|
||
|
* Getter for data
|
||
|
*/
|
||
|
get data$(): Observable<any>
|
||
|
{
|
||
|
return this._data.asObservable();
|
||
|
}
|
||
|
|
||
|
// -----------------------------------------------------------------------------------------------------
|
||
|
// @ Public methods
|
||
|
// -----------------------------------------------------------------------------------------------------
|
||
|
|
||
|
/**
|
||
|
* Get data
|
||
|
*/
|
||
|
getData(): Observable<any>
|
||
|
{
|
||
|
return this._httpClient.get('api/dashboards/project').pipe(
|
||
|
tap((response: any) => {
|
||
|
this._data.next(response);
|
||
|
})
|
||
|
);
|
||
|
}
|
||
|
}
|