How to use the esp-js.Guard.isString function in esp-js

To help you get started, we’ve selected a few esp-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esp / esp-js / packages / esp-js-ui / src / ui / state / stateService.ts View on Github external
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);
    }
github esp / esp-js / packages / esp-js-ui / src / ui / state / stateService.ts View on Github external
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);
    }
github esp / esp-js / packages / esp-js-ui / src / ui / state / stateService.ts View on Github external
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);
    }
github esp / esp-js / packages / esp-js-react / src / viewBindingDecorator.ts View on Github external
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);
    };
}
github esp / esp-js / packages / esp-js-ui / src / core / observableExt / subscribeWithRouter.ts View on Github external
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;
github esp / esp-js / packages / esp-js-ui / src / ui / components / componentDecorator.ts View on Github external
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');
    }
}
github esp / esp-js / packages / esp-js-ui / src / ui / modelBase.ts View on Github external
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}`);
    }
github esp / esp-js / packages / esp-js-ui / src / ui / components / componentDecorator.ts View on Github external
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');
    }
}
github esp / esp-js / packages / esp-js-ui / src / ui / state / stateService.ts View on Github external
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;
    }