Number Helpers API reference for Number Helpers in Semantic UI's reactivity system hash API 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

NameTypeDefaultDescription
amountnumber1How much to add
maxnumberOptional 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

NameTypeDefaultDescription
amountnumber1How much to subtract
minnumberOptional 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