Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public saveModuleState(moduleKey:string, layoutMode:string, state:T): void {
Guard.isString(moduleKey, 'appKey must be a string');
Guard.isString(layoutMode, 'layoutMode must be a string');
Guard.isDefined(state, 'state must be a defined');
let stateJson = JSON.stringify(state);
let stateKey = this._getStateKey(moduleKey, layoutMode);
_log.debug(`saving layout state for key ${stateKey}. State:${stateJson}`, state);
localStorage.setItem(stateKey, stateJson);
}
public saveModuleState(moduleKey:string, layoutMode:string, state:T): void {
Guard.isString(moduleKey, 'appKey must be a string');
Guard.isString(layoutMode, 'layoutMode must be a string');
Guard.isDefined(state, 'state must be a defined');
let stateJson = JSON.stringify(state);
let stateKey = this._getStateKey(moduleKey, layoutMode);
_log.debug(`saving layout state for key ${stateKey}. State:${stateJson}`, state);
localStorage.setItem(stateKey, stateJson);
}
public clearModuleState(moduleKey:string, layoutMode:string): void {
Guard.isString(moduleKey, 'moduleKey must be a string');
Guard.isDefined(layoutMode, 'layoutMode must be a defined');
let stateKey = this._getStateKey(moduleKey, layoutMode);
localStorage.removeItem(stateKey);
}
export function viewBinding(view: any, displayContext: string = DEFAULT_VIEW_KEY) {
Guard.isDefined(view, 'view must be defined');
Guard.isString(displayContext, 'displayContext must be a string');
return function (target) {
let viewMetadata = getMetadata(target);
if (viewMetadata.hasRegisteredViewContext(displayContext)) {
throw new Error(`Context ${displayContext} already registered for view`);
}
viewMetadata.viewRegistrations[displayContext] = new ViewMetadataRegistration(view, displayContext);
};
}
Rx.Observable.prototype.subscribeWithRouter = function (
router: Router,
modelId: string,
onNext?: (value: T, model: TModel) => void,
onError?: (exception: any, model: TModel) => void,
onCompleted?: (model: TModel) => void): Rx.Disposable {
Guard.isDefined(router, 'router should be defined');
Guard.isString(modelId, 'modelId should be defined and a string');
let source = this;
return source.materialize().subscribe(i => {
switch (i.kind) {
case 'N':
if (onNext !== null && onNext !== undefined) {
router.runAction(modelId, model => onNext(i.value, model));
}
break;
case 'E':
if (onError === null || onError === undefined) {
throw i.error;
} else {
router.runAction(modelId, model => onError(i.error, model));
}
break;
constructor(public readonly componentKey: string, public readonly shortName: string, public readonly customMetadata?: any) {
Guard.isString(componentKey, 'componentKey must be defined and be a string');
Guard.isString(shortName, 'shortName must be defined and be a string');
}
}
constructor(protected _modelId:string, protected _router:Router) {
super();
Guard.isString(_modelId, 'modelId required and must be a string');
Guard.isDefined(_router, 'router required');
this._log = Logger.create(`ModelBase-${_modelId}`);
}
constructor(public readonly componentKey: string, public readonly shortName: string, public readonly customMetadata?: any) {
Guard.isString(componentKey, 'componentKey must be defined and be a string');
Guard.isString(shortName, 'shortName must be defined and be a string');
}
}
public getModuleState(moduleKey:string, layoutMode:string): T {
Guard.isString(moduleKey, 'moduleKey must be a string');
Guard.isDefined(layoutMode, 'layoutMode must be a defined');
let stateKey = this._getStateKey(moduleKey, layoutMode);
let state = localStorage.getItem(stateKey);
return state ? JSON.parse(state) : null;
}