Skip to content

Instantly share code, notes, and snippets.

@elyphas
Last active October 6, 2019 00:31
Show Gist options
  • Save elyphas/f55e6d6b3f02e17f775cec76af14d380 to your computer and use it in GitHub Desktop.
Save elyphas/f55e6d6b3f02e17f775cec76af14d380 to your computer and use it in GitHub Desktop.
def cmpInput444(lbl: String, hdl: Handler[String], props: VDomModifier, events: VDomModifier) =
div( id := "txt" + lbl,
float.left, props,
label( lbl, props ),
input ( key := "txt" + lbl,
value <-- hdl.map ( t => if(t == "0") "" else t ),
onKeyUp.map { k =>
val txt = k.currentTarget.asInstanceOf[html.Input]
if(txt.value == "") "0" else txt.value
} --> hdl,
//onChange.target.value --> hdl,
props, events
)
)
val getIdComparative: Observable[String] = (txtEjercicio: Observable[Int], txtFolio: Observable[Int])
.parMapN{ case (ejercicio: Int, folio: Int) =>
folio + "-" + ejercicio + "-" + "ADQ2"
}
val ver = SinkObserver.create[String]{ id => store.store.onNext(store.UpdateIdComparative(id))
}
val onChangeDebounce = onKeyUp.debounce( 500 milliseconds).transform (
_.lift[Observable].withLatestFrom(getIdComparative)
{ case (event, id) => id } ) --> ver // --> store.store
cmpInput444("Folio", txtFolio.mapHandler[String]( _.toInt )(_.toString), VDomModifier(width:="75px"), VDomModifier(onChangeDebounce))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment