vigour-is

"is" api for observables (observes until a value fulfils conditions) build-in promise support

Usage no npm install needed!

<script type="module">
  import vigourIs from 'https://cdn.skypack.dev/vigour-is';
</script>

README

vigour-is

Build Status js-standard-style npm version Coverage Status

.is api for observables (observes until a value fulfils conditions)

  // add a once listener
  obs.is('something', () => {
    console.log('fire!')
  })

  // fire!
  obs.set('something')

  // fire immediatly
  obs.is('something', (data, stamp, target) => {
    console.log('fire!')
  })

  // fire immmediatly, as a promise
  obs.is('something').then(() => {
    console.log('fire')
  })

  // fire immmediatly, as a promise
  obs.is('something').then((target, data, stamp) => {
    console.log('fire', target, data, stamp)
  })

  // use a compare function
  obs.is((val, data, stamp, target) => val === 'hello')
    .then((target, data, stamp) => {
      console.log('fire', target, data, stamp)
    })