Number Helpers API reference for Number Helpers in Semantic UI's reactivity system hash Guide

Number Helpers

Number Helpers are methods available on Signal instances that contain numeric values. These helpers provide convenient ways to manipulate and update numeric signals.

increment

Increases the value of the Signal by a specified amount or by 1 if no amount is provided.

Syntax

signal.increment(amount?)

Parameters

NameTypeDescription
amountNumber(Optional) The amount to increment by. Defaults to 1 if not specified.
maxNumber(Optional) The maximum value allowed to increment to.

Usage

import { Signal } from '@semantic-ui/reactivity';
const counter = new Signal(0);
counter.increment(); // value is now 1
counter.increment(5); // value is now 6
counter.increment(1, 10); // value will not exceed 10

Example

decrement

Decreases the value of the Signal by a specified amount or by 1 if no amount is provided.

Syntax

signal.decrement(amount?)

Parameters

NameTypeDescription
amountNumber(Optional) The amount to decrement by. Defaults to 1 if not specified.
minNumber(Optional) The minimum value allowed to increment to.

Usage

import { Signal } from '@semantic-ui/reactivity';
const score = new Signal(100);
score.decrement(); // value is now 99
score.decrement(10); // value is now 89
score.decrement(1, 0); // value will not reduce below 0

Example

Previous
Dependency
Next
Boolean Helpers