knockout-contrib

:metal: KnockoutJS Goodies Monorepo

View the Project on GitHub Profiscience/knockout-contrib

utils.once

Version Dependency Status Peer Dependency Status Dev Dependency Status Downloads

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

Creates a subscription that is called once and then disposed. Returns subscription for early disposal if necessary.

Usage

import { once } from '@profiscience/knockout-contrib'

const foo = ko.observable(0)

const sub = once(foo, () => console.log('hit!'))

foo(1)
// hit!

foo(2)
// nothing...