diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-12-11 17:36:46 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-12 10:58:16 +0100 |
commit | 63c4db6d71b98523753c51747e308682d9a2e8a0 (patch) | |
tree | d26c0d092ce016f2afe56bf71b08ca4698fe673f /client/src/app/app.service.ts | |
parent | 908f6e5e38e85cc0debab0051b7fa34b13025f96 (diff) | |
download | PeerTube-63c4db6d71b98523753c51747e308682d9a2e8a0.tar.gz PeerTube-63c4db6d71b98523753c51747e308682d9a2e8a0.tar.zst PeerTube-63c4db6d71b98523753c51747e308682d9a2e8a0.zip |
Move to angular cli
Diffstat (limited to 'client/src/app/app.service.ts')
-rw-r--r-- | client/src/app/app.service.ts | 48 |
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 | |||
3 | import { Injectable } from '@angular/core' | ||
4 | |||
5 | export type InternalStateType = { | ||
6 | [key: string]: any | ||
7 | } | ||
8 | |||
9 | @Injectable() | ||
10 | export 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 | } | ||