@activejs/core
Version:
Pragmatic, Reactive State Management for JavaScript Apps
63 lines (62 loc) • 2.01 kB
TypeScript
import { UnitConfig } from '../models';
import { UnitBase } from './abstract-unit-base';
export interface StringUnit extends String {
}
/**
* StringUnit is a reactive storage Unit that emulates `string`.
*
* It only accepts `string` data type as its value.
* It ensures that at any point of time the value would always be `string`.
*
* StringUnit implements all the `String.prototype` methods that are available
* in the environment/browser its running, including polyfills.
* e.g.: `trim`, `match`, `includes`, etc.
*
* Learn more about Units [here](https://docs.activejs.dev/fundamentals/units). \
* Learn more about StringUnit [here](https://docs.activejs.dev/fundamentals/units/stringunit).
*
* Just like every other ActiveJS Unit:
* - StringUnit extends {@link UnitBase}
* - Which further extends {@link Base} and `Observable`
*
* @category 1. Units
*/
export declare class StringUnit extends UnitBase<string> {
/**
* Length of the string {@link value}.
*/
get length(): number;
/**
* Current value of the Unit.
* @default `''` (empty string)
*
* @category Access Value
*/
value(): string;
/**
* @internal please do not use.
*/
protected defaultValue(): string;
constructor(config?: UnitConfig<string>);
/**
* Extends {@link UnitBase.wouldDispatch} and adds additional check for type string,
* which cannot be bypassed even by using {@link force}.
*
* @param value The value to be dispatched.
* @param force Whether dispatch-checks should be bypassed or not.
* @returns A boolean indicating whether the param `value` would pass the dispatch-checks if dispatched.
*
* @category Common Units
*/
wouldDispatch(value: string, force?: boolean): boolean;
/**
* @internal please do not use.
*/
protected isValidValue(value: any): boolean;
/**
* @deprecated
* @ignore
* @internal please do not use.
*/
static String: any;
}