diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 14:32:15 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 14:32:15 +0200 |
commit | df98563e2104b82b119c00a3cd83cd0dc1242d25 (patch) | |
tree | a9720bf01bac9ad5646bd3d3c9bc7653617afdad /client/src/app/app.service.ts | |
parent | 46757b477c1adb5f98060d15998a3852e18902a6 (diff) | |
download | PeerTube-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.ts | 20 |
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 @@ | |||
1 | import { Injectable } from '@angular/core'; | 1 | /* tslint:disable */ |
2 | |||
3 | import { Injectable } from '@angular/core' | ||
2 | 4 | ||
3 | export type InternalStateType = { | 5 | export type InternalStateType = { |
4 | [key: string]: any | 6 | [key: string]: any |
5 | }; | 7 | } |
6 | 8 | ||
7 | @Injectable() | 9 | @Injectable() |
8 | export class AppState { | 10 | export 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 | } |