/brisky-is

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

Primary LanguageJavaScriptISC LicenseISC

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)
    })