diff options
author | 2019-11-20 11:32:53 +0200 | |
---|---|---|
committer | 2019-11-21 12:20:55 +0200 | |
commit | 6ee4d31800a68975294ef11156bea9a595b23adf (patch) | |
tree | 23ab53c05a1f5908e106b4830985db0c52df8dc8 /cds-ui/client-frankfurt/src/app/common/core/stores/Store.ts | |
parent | f0b747065e11ee5cc1be4bad2983a557af9c7969 (diff) |
add pacakges dashboard component to new cds ui
Issue-ID: CCSDK-1951
Signed-off-by: Ahmed Abbas <ahmad.helmy@orange.com>
Change-Id: I0c320e5f49a50e442068f5af1fd79c41c97bb74d
Diffstat (limited to 'cds-ui/client-frankfurt/src/app/common/core/stores/Store.ts')
-rw-r--r-- | cds-ui/client-frankfurt/src/app/common/core/stores/Store.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/cds-ui/client-frankfurt/src/app/common/core/stores/Store.ts b/cds-ui/client-frankfurt/src/app/common/core/stores/Store.ts new file mode 100644 index 000000000..1d5b0afc1 --- /dev/null +++ b/cds-ui/client-frankfurt/src/app/common/core/stores/Store.ts @@ -0,0 +1,22 @@ +import {Observable, BehaviorSubject} from 'rxjs'; +import { Injectable } from '@angular/core'; + +export class Store<T> { + state$: Observable<T>; + private subject: BehaviorSubject<T>; + + protected constructor(initialState: T) { + this.subject = new BehaviorSubject(initialState); + this.state$ = this.subject.asObservable(); + } + + get state(): T { + return this.subject.getValue(); + } + + protected setState(nextState: T): void { + console.log('setting state', this.subject); + this.subject.next(nextState); + } + +} |