• Creates a Counter object with an optional initialValue, defaults to 0.

    Example

    Create a countdown

    const clickCountdown = counter(10);

    const handleClickEvent = () => {
    clickCountdown.dec();

    if(isZero(clickCountdown.get())) {
    console.log("0");
    clickCountdown.set(5);
    }
    };

    Returns

    the Counter object

    Parameters

    • initialValue: number = 0

      the initial value

    Returns Counter

Generated using TypeDoc