@activejs/core
Version:
Pragmatic, Reactive State Management for JavaScript Apps
59 lines (58 loc) • 1.9 kB
TypeScript
import { UnitConfig } from '../models';
import { UnitBase } from './abstract-unit-base';
export interface NumUnit extends Number {
}
/**
* NumUnit is a reactive storage Unit that emulates `number`.
*
* It only accepts `number` data type as its value.
* It ensures that at any point of time the value would always be `number`.
*
* NumUnit implements all the `Number.prototype` methods that are available
* in the environment/browser its running, including polyfills.
* e.g.: `toFixed`, `toPrecision`, etc.
*
* Learn more about Units [here](https://docs.activejs.dev/fundamentals/units). \
* Learn more about NumUnit [here](https://docs.activejs.dev/fundamentals/units/numunit).
*
* Just like every other ActiveJS Unit:
* - NumUnit extends {@link UnitBase}
* - Which further extends {@link Base} and `Observable`
*
* @category 1. Units
*/
export declare class NumUnit extends UnitBase<number> {
/**
* Current value of the Unit.
* @default `0` (number zero)
*
* @category Access Value
*/
value(): number;
/**
* @internal please do not use.
*/
protected defaultValue(): number;
constructor(config?: UnitConfig<number>);
/**
* Extends {@link UnitBase.wouldDispatch} and adds additional check for type number,
* which cannot be bypassed even by using param `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: number, force?: boolean): boolean;
/**
* @internal please do not use.
*/
protected isValidValue(value: any): boolean;
/**
* @deprecated
* @ignore
* @internal please do not use.
*/
static Number: any;
}