Number HelpersAPI reference for Number Helpers in Semantic UI's reactivity systemhashAPI Reference
Categories

Number Helpers

Signal helpers for numeric values. Step the stored number up or down in place, with optional clamping, instead of a read-mutate-write round trip.

Stepping

increment

signal.increment(amount, max);

Adds amount to the stored value, notifying dependents when it changes. Equivalent to signal.mutate(value => value + amount), with an optional ceiling.

Parameters

Name Type Default Description
amount number 1 How much to add
max number Optional ceiling the result will not exceed

Usage

import { signal } from '@semantic-ui/reactivity';
const count = signal(0);
count.increment(); // 1
count.increment(5); // 6
count.increment(10, 8); // clamped to 8

max clamps the result of this call only. It is not a persistent bound, so a later increment() without a max can push past it.

Example

decrement

signal.decrement(amount, min);

Subtracts amount from the stored value, notifying dependents when it changes. Equivalent to signal.mutate(value => value - amount), with an optional floor.

Parameters

Name Type Default Description
amount number 1 How much to subtract
min number Optional floor the result will not fall below

Usage

import { signal } from '@semantic-ui/reactivity';
const score = signal(100);
score.decrement(); // 99
score.decrement(10); // 89
score.decrement(50, 0); // clamped to 0

min clamps the result of this call only. It is not a persistent bound, so a later decrement() without a min can drop below it.

Example

Previous
Dependency
Next
Boolean Helpers