aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/app.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/app.service.ts')
-rw-r--r--client/src/app/app.service.ts48
1 files changed, 0 insertions, 48 deletions
diff --git a/client/src/app/app.service.ts b/client/src/app/app.service.ts
deleted file mode 100644
index abffc87f1..000000000
--- a/client/src/app/app.service.ts
+++ /dev/null
@@ -1,48 +0,0 @@
1/* tslint:disable */
2
3import { Injectable } from '@angular/core'
4
5export type InternalStateType = {
6 [key: string]: any
7}
8
9@Injectable()
10export class AppState {
11
12 public _state: InternalStateType = { }
13
14 /**
15 * Already return a clone of the current state.
16 */
17 public get state() {
18 return this._state = this._clone(this._state)
19 }
20 /**
21 * Never allow mutation
22 */
23 public set state(value) {
24 throw new Error('do not mutate the `.state` directly')
25 }
26
27 public get(prop?: any) {
28 /**
29 * Use our state getter for the clone.
30 */
31 const state = this.state
32 return state.hasOwnProperty(prop) ? state[prop] : state
33 }
34
35 public set(prop: string, value: any) {
36 /**
37 * Internally mutate our state.
38 */
39 return this._state[prop] = value
40 }
41
42 private _clone(object: InternalStateType) {
43 /**
44 * Simple object clone.
45 */
46 return JSON.parse(JSON.stringify( object ))
47 }
48}