knockout-contrib

:metal: KnockoutJS Goodies Monorepo

View the Project on GitHub Profiscience/knockout-contrib

utils.increment / utils.decrement

Version Dependency Status Peer Dependency Status Dev Dependency Status Downloads

This package is intended for consumption via the [@profiscience/knockout-contrib] metapackage.

Increments/decrements a numeric observable. Returns the new value.

Usage

import { increment, decrement } from '@profiscience/knockout-contrib'

const foo = ko.observable(0)

increment(foo) // 1
increment(foo, 3) // 4
decrement(foo) // 3
decrement(foo, 2) // 1