src/reducer.js
function (state, action) {
    // Apply coniditions to view cells
    let normalized
    let view
    if (state.unnormalizedModel) {
      normalized = normalizeModelAndView({
        model: state.unnormalizedModel,
        view: action.view
      })

      view = evaluateViewConditions(normalized.view, state.value)
    } else {
      view = evaluateViewConditions(state.baseView, state.value)
      normalized = {
        view,
        model: state.model
      }
    }

    const newState = {
      baseView: normalized.view,
      lastAction: CHANGE_VIEW,
      unnormalizedView: action.view,
      view
    }

    if (!_.isEqual(state.baseModel, normalized.model)) {
      Object.assign(newState, {
        baseModel: normalized.model,
        model: evaluateConditions(normalized.model, state.value, undefined, state.value)
      })
    }

    return _.defaults(newState, state)
  }
function (state, action) {
    // Apply coniditions to view cells
    let normalized
    let view
    if (state.unnormalizedModel) {
      normalized = normalizeModelAndView({
        model: state.unnormalizedModel,
        view: action.view
      })

      view = evaluateViewConditions(normalized.view, state.value)
    } else {
      view = evaluateViewConditions(state.baseView, state.value)
      normalized = {
        view,
        model: state.model
      }
    }

    const newState = {
      baseView: normalized.view,
      lastAction: CHANGE_VIEW,
      unnormalizedView: action.view,
      view
    }

    if (!_.isEqual(state.baseModel, normalized.model)) {
      Object.assign(newState, {
        baseModel: normalized.model,
        model: evaluateConditions(normalized.model, state.value, undefined, state.value)
      })
    }

    return _.defaults(newState, state)
  }
function ( state , action ) { // Apply coniditions to view cells let normalized let view if ( state . unnormalizedModel ) { normalized = normalizeModelAndView ( { model : state . unnormalizedModel , view : action . view } ) view = evaluateViewConditions ( normalized . view , state . value ) } else { view = evaluateViewConditions ( state . baseView , state . value ) normalized = { view , model : state . model } } const newState = { baseView : normalized . view , lastAction : CHANGE_VIEW , unnormalizedView : action . view , view } if ( ! _ . isEqual ( state . baseModel , normalized . model ) ) { Object . assign ( newState , { baseModel : normalized . model , model : evaluateConditions ( normalized . model , state . value , undefined , state . value ) } ) } return _ . defaults ( newState , state ) }
Update the bunsen model
@param {State} state - state to update
@param {Action} action - action
@returns {State} - updated state
Update the bunsen model