summaryrefslogtreecommitdiffstats
path: root/cds-ui/client-frankfurt/src/app/common/core/stores/Store.ts
diff options
context:
space:
mode:
authorBrinda Santh Muthuramalingam <brindasanth@in.ibm.com>2019-11-26 15:31:39 +0000
committerGerrit Code Review <gerrit@onap.org>2019-11-26 15:31:39 +0000
commit32b4021333213679c6a77ca50c9bba07e47c5b9b (patch)
tree74c6fae30d18f7011c9c2c24609e2647f5183442 /cds-ui/client-frankfurt/src/app/common/core/stores/Store.ts
parentadbbdf4f899833229f7244af91e4deb379a3a942 (diff)
parent6ee4d31800a68975294ef11156bea9a595b23adf (diff)
Merge "add pacakges dashboard component to new cds ui"
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.ts22
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);
+ }
+
+}