X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fapp.service.ts;h=abffc87f195c520bffa86c53f504d0045b0188ea;hb=3d09cdbf90902894c841d0a5ddb35eb772c53b8b;hp=033c21900affe152a7221f5edd8428ec51aee103;hpb=a6375e69668ea42e19531c6bc68dcd37f3f7cbd7;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/app.service.ts b/client/src/app/app.service.ts index 033c21900..abffc87f1 100644 --- a/client/src/app/app.service.ts +++ b/client/src/app/app.service.ts @@ -1,36 +1,48 @@ +/* tslint:disable */ -import { Injectable } from '@angular/core'; +import { Injectable } from '@angular/core' + +export type InternalStateType = { + [key: string]: any +} @Injectable() export class AppState { - _state = { }; - constructor() { ; } + public _state: InternalStateType = { } - // already return a clone of the current state - get state() { - return this._state = this._clone(this._state); + /** + * Already return a clone of the current state. + */ + public get state() { + return this._state = this._clone(this._state) } - // never allow mutation - set state(value) { - throw new Error('do not mutate the `.state` directly'); + /** + * Never allow mutation + */ + public set state(value) { + throw new Error('do not mutate the `.state` directly') } - - get(prop?: any) { - // use our state getter for the clone - const state = this.state; - return state.hasOwnProperty(prop) ? state[prop] : state; + public get(prop?: any) { + /** + * Use our state getter for the clone. + */ + const state = this.state + return state.hasOwnProperty(prop) ? state[prop] : state } - set(prop: string, value: any) { - // internally mutate our state - return this._state[prop] = value; + public set(prop: string, value: any) { + /** + * Internally mutate our state. + */ + return this._state[prop] = value } - - _clone(object) { - // simple object clone - return JSON.parse(JSON.stringify( object )); + private _clone(object: InternalStateType) { + /** + * Simple object clone. + */ + return JSON.parse(JSON.stringify( object )) } }