src/Settings.js
/**
 * Hold on to event when hold_property is true, and only keep them if
 * accept_property is true (when hold_property becomes false).
 */
Hold on to event when hold_property is true, and only keep them if
accept_property is true (when hold_property becomes false).
Hold on to event when hold_property is true and only keep them if accept_property is true ( when hold_property becomes false ) .
function convertToConditionalStream (valueStream, statusStream) {
  const init = {
    savedValue: null,
    currentValue: null,
    lastStatus: null
  }
  const held = bacon.combineAsArray(valueStream, statusStream.toProperty(null))
        .scan(init, ({ savedValue, currentValue, lastStatus }, [ value, status ]) => {
          const newStatus = lastStatus !== status
          if (newStatus && status === 'hold') {
            return {
              savedValue: currentValue,
              currentValue,
              lastStatus: status
            }
          } else if (!newStatus && status === 'hold') {
            return {
              savedValue,
              currentValue: value,
              lastStatus: status
            }
          } else if (newStatus && status === 'abandon') {
            return {
              savedValue: null,
              currentValue: savedValue,
              lastStatus: status
            }
          } else if (newStatus && status === 'accept') {
            return {
              savedValue: null,
              currentValue,
              lastStatus: status
            }
          } else {
            return {
              savedValue: null,
              currentValue: value,
              lastStatus: status
            }
          }
        })
        .skip(1)
        .map(({ currentValue }) => currentValue)
        .skipDuplicates()
  return held
}
function convertToConditionalStream ( valueStream , statusStream ) { const init = { savedValue : null , currentValue : null , lastStatus : null } const held = bacon . combineAsArray ( valueStream , statusStream . toProperty ( null ) ) . scan ( init , ( { savedValue , currentValue , lastStatus } , [ value , status ] ) => { const newStatus = lastStatus !== status if ( newStatus && status === 'hold' ) { return { savedValue : currentValue , currentValue , lastStatus : status } } else if ( ! newStatus && status === 'hold' ) { return { savedValue , currentValue : value , lastStatus : status } } else if ( newStatus && status === 'abandon' ) { return { savedValue : null , currentValue : savedValue , lastStatus : status } } else if ( newStatus && status === 'accept' ) { return { savedValue : null , currentValue , lastStatus : status } } else { return { savedValue : null , currentValue : value , lastStatus : status } } } ) . skip ( 1 ) . map ( ( { currentValue } ) => currentValue ) . skipDuplicates ( ) return held }
Hold on to event when hold_property is true, and only keep them if
 accept_property is true (when hold_property becomes false).
Hold on to event when hold_property is true and only keep them if accept_property is true ( when hold_property becomes false ) .
// Combine values with status to revert to last value when a reject is passed. // See if the status was just set // Record the currentValue as the savedValue // Record the current value, and keep the savedValue unchanged // Keep the saved value // Keep the new value // Not held, so keep the value // Skip the initial null value // Get the current value // Skip duplicate values