examples/04-bmi-counter/index.js
function model(M, prop) {
  const bmiLens = L(
    prop,
    // if we don't have <prop> property yet, then use these default values
    L.defaults({weight: 80, height: 180}),
    // add "read-only" bmi property to our BMI model that is derived from weight and height
    L.augment({bmi: ({weight: w, height: h}) => Math.round(w / (h * h * 0.0001))})
  )
  return M.lens(bmiLens)
}
function model(M, prop) {
  const bmiLens = L(
    prop,
    // if we don't have <prop> property yet, then use these default values
    L.defaults({weight: 80, height: 180}),
    // add "read-only" bmi property to our BMI model that is derived from weight and height
    L.augment({bmi: ({weight: w, height: h}) => Math.round(w / (h * h * 0.0001))})
  )
  return M.lens(bmiLens)
}
function model ( M , prop ) { const bmiLens = L ( prop , // if we don't have <prop> property yet, then use these default values L . defaults ( { weight : 80 , height : 180 } ) , // add "read-only" bmi property to our BMI model that is derived from weight and height L . augment ( { bmi : ( { weight : w , height : h } ) => Math . round ( w / ( h * h * 0.0001 ) ) } ) ) return M . lens ( bmiLens ) }
Let's define the model function so that it takes the parent state and property containing the BMI counter state. We are making this BMI model as a separate function so that we could re-use it if needed
Let s define the model function so that it takes the parent state and property containing the BMI counter state . We are making this BMI model as a separate function so that we could re - use it if needed