On This Page
Stepping
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(); // 1count.increment(5); // 6count.increment(10, 8); // clamped to 8max clamps the result of this call only. It is not a persistent bound, so a later increment() without a max can push past it.
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(); // 99score.decrement(10); // 89score.decrement(50, 0); // clamped to 0min clamps the result of this call only. It is not a persistent bound, so a later decrement() without a min can drop below it.
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.