utils.modify
This package is intended for consumption via the [@profiscience/knockout-contrib] metapackage
Modifies an observable using a transform function. Returns the new value.
Useful for wrapping general purpose utilities functions for Knockout observables.
Usage
import { modify } from '@profiscience/knockout-contrib'
const foobar = ko.observable('foobar')
function reverseString(str) {
return str
.split('')
.reverse()
.join('')
}
const ret = modify(foobar, reverseString)
;(foobar() === ret) === 'raboof'