aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/app.service.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-01-13 12:16:00 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-01-13 12:16:00 +0100
commitc16ce1de8e8c21ad2136335d3b0b7d230e6d2f24 (patch)
treee5177a26dae755833122c4ef73744c2a7f9b53fc /client/src/app/app.service.ts
parent80deae8d198f6a376b477d780e76966f8fbb72ce (diff)
downloadPeerTube-c16ce1de8e8c21ad2136335d3b0b7d230e6d2f24.tar.gz
PeerTube-c16ce1de8e8c21ad2136335d3b0b7d230e6d2f24.tar.zst
PeerTube-c16ce1de8e8c21ad2136335d3b0b7d230e6d2f24.zip
Client: add basic aot support
Diffstat (limited to 'client/src/app/app.service.ts')
-rw-r--r--client/src/app/app.service.ts20
1 files changed, 10 insertions, 10 deletions
diff --git a/client/src/app/app.service.ts b/client/src/app/app.service.ts
index 033c21900..9b582e472 100644
--- a/client/src/app/app.service.ts
+++ b/client/src/app/app.service.ts
@@ -1,35 +1,35 @@
1
2import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
3 2
3export type InternalStateType = {
4 [key: string]: any
5};
6
4@Injectable() 7@Injectable()
5export class AppState { 8export class AppState {
6 _state = { };
7 9
8 constructor() { ; } 10 public _state: InternalStateType = { };
9 11
10 // already return a clone of the current state 12 // already return a clone of the current state
11 get state() { 13 public get state() {
12 return this._state = this._clone(this._state); 14 return this._state = this._clone(this._state);
13 } 15 }
14 // never allow mutation 16 // never allow mutation
15 set state(value) { 17 public set state(value) {
16 throw new Error('do not mutate the `.state` directly'); 18 throw new Error('do not mutate the `.state` directly');
17 } 19 }
18 20
19 21 public get(prop?: any) {
20 get(prop?: any) {
21 // use our state getter for the clone 22 // use our state getter for the clone
22 const state = this.state; 23 const state = this.state;
23 return state.hasOwnProperty(prop) ? state[prop] : state; 24 return state.hasOwnProperty(prop) ? state[prop] : state;
24 } 25 }
25 26
26 set(prop: string, value: any) { 27 public set(prop: string, value: any) {
27 // internally mutate our state 28 // internally mutate our state
28 return this._state[prop] = value; 29 return this._state[prop] = value;
29 } 30 }
30 31
31 32 private _clone(object: InternalStateType) {
32 _clone(object) {
33 // simple object clone 33 // simple object clone
34 return JSON.parse(JSON.stringify( object )); 34 return JSON.parse(JSON.stringify( object ));
35 } 35 }