@profiscience/knockout-contrib-utils-once
v2.0.1
Published
[![Version][npm-version-shield]][npm] [![Dependency Status][david-dm-shield]][david-dm] [![Peer Dependency Status][david-dm-peer-shield]][david-dm-peer] [![Dev Dependency Status][david-dm-dev-shield]][david-dm-dev] [![Downloads][npm-stats-shield]][npm-sta
Downloads
54
Readme
utils.once
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...