aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/app.service.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-16 14:32:15 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-16 14:32:15 +0200
commitdf98563e2104b82b119c00a3cd83cd0dc1242d25 (patch)
treea9720bf01bac9ad5646bd3d3c9bc7653617afdad /client/src/app/app.service.ts
parent46757b477c1adb5f98060d15998a3852e18902a6 (diff)
downloadPeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.gz
PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.zst
PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.zip
Use typescript standard and lint all files
Diffstat (limited to 'client/src/app/app.service.ts')
-rw-r--r--client/src/app/app.service.ts20
1 files changed, 11 insertions, 9 deletions
diff --git a/client/src/app/app.service.ts b/client/src/app/app.service.ts
index a7eb880a4..abffc87f1 100644
--- a/client/src/app/app.service.ts
+++ b/client/src/app/app.service.ts
@@ -1,46 +1,48 @@
1import { Injectable } from '@angular/core'; 1/* tslint:disable */
2
3import { Injectable } from '@angular/core'
2 4
3export type InternalStateType = { 5export type InternalStateType = {
4 [key: string]: any 6 [key: string]: any
5}; 7}
6 8
7@Injectable() 9@Injectable()
8export class AppState { 10export class AppState {
9 11
10 public _state: InternalStateType = { }; 12 public _state: InternalStateType = { }
11 13
12 /** 14 /**
13 * Already return a clone of the current state. 15 * Already return a clone of the current state.
14 */ 16 */
15 public get state() { 17 public get state() {
16 return this._state = this._clone(this._state); 18 return this._state = this._clone(this._state)
17 } 19 }
18 /** 20 /**
19 * Never allow mutation 21 * Never allow mutation
20 */ 22 */
21 public set state(value) { 23 public set state(value) {
22 throw new Error('do not mutate the `.state` directly'); 24 throw new Error('do not mutate the `.state` directly')
23 } 25 }
24 26
25 public get(prop?: any) { 27 public get(prop?: any) {
26 /** 28 /**
27 * Use our state getter for the clone. 29 * Use our state getter for the clone.
28 */ 30 */
29 const state = this.state; 31 const state = this.state
30 return state.hasOwnProperty(prop) ? state[prop] : state; 32 return state.hasOwnProperty(prop) ? state[prop] : state
31 } 33 }
32 34
33 public set(prop: string, value: any) { 35 public set(prop: string, value: any) {
34 /** 36 /**
35 * Internally mutate our state. 37 * Internally mutate our state.
36 */ 38 */
37 return this._state[prop] = value; 39 return this._state[prop] = value
38 } 40 }
39 41
40 private _clone(object: InternalStateType) { 42 private _clone(object: InternalStateType) {
41 /** 43 /**
42 * Simple object clone. 44 * Simple object clone.
43 */ 45 */
44 return JSON.parse(JSON.stringify( object )); 46 return JSON.parse(JSON.stringify( object ))
45 } 47 }
46} 48}