by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Sep 17 17:12
    cornerman synchronize #442
  • Sep 15 12:25
    cornerman closed #444
  • Sep 15 12:25

    cornerman on master

    move snabbdom facade into own p… (compare)

  • Sep 15 12:25
    cornerman closed #457
  • Sep 15 12:20
    cornerman opened #457
  • Sep 15 12:19
    cornerman synchronize #441
  • Sep 15 12:06
    cornerman edited #441
  • Sep 15 12:06
    cornerman edited #441
  • Sep 15 12:06
    cornerman edited #441
  • Sep 15 12:04
    cornerman edited #441
  • Sep 15 10:45
    cornerman edited #452
  • Sep 15 10:44
    cornerman edited #455
  • Sep 15 10:44
    cornerman milestoned #455
  • Sep 15 10:44
    cornerman milestoned #456
  • Sep 15 10:44
    cornerman opened #456
  • Sep 15 08:29
    fdietze commented #454
  • Sep 14 21:21
    cornerman opened #455
  • Sep 14 18:50
    cornerman commented #276
  • Sep 14 18:49
    fdietze commented #276
  • Sep 14 18:00
    cornerman commented #276
elyphas
@elyphas
Hi, any idea? to manage this situation Try:
def cmpInputNumber(lbl: String, hdl: Handler[Int],
               props: VDomModifier = VDomModifier.empty,
               events: Option[VDomModifier] = None,
               inputType: String = "input") = {

        cmpInput(lbl,
                hdl.mapSubject[String]{ x =>
                    Try {
                      x.toInt
                    } match {
                      case Success(value) => value
                      case Failure(exception) =>
                        alert("Hubo un error line:172 from inputs in outwatch_components " + exception.getMessage())
                        0
                    }
                }{ f: Int => if (f <= 0) "" else f.toString},
            props, events, inputType
        )
  }
moritz bust
@busti
@elyphas Sorry, I am a bit lost here. What does the other apply call behind the map call do?
Also that match behind the try creation does not do anything, right? Because it will always be Success
elyphas
@elyphas
@busti ;
do You mean? cmpInput
def cmpInput(lbl: String, hdl: Handler[String],
                  props: VDomModifier = VDomModifier.empty,
                  events: Option[VDomModifier] = None,
                  inputType: String = "input",
                  ) = {

      val vDom = VDomModifier ( id:= "txt" + lbl, key := "txt" + lbl, display.block,
                  value <-- hdl,
                  onKeyUp.map { k =>
                      val txt = k.currentTarget.asInstanceOf[html.Input]
                      if ( txt.value == "" ) "" else txt.value
                  } --> hdl,
                  props, events.getOrElse(VDomModifier.empty)
              )

      val txtComponent = if (inputType == "input") input(vDom) else textArea(vDom)

      div( id := "div" + lbl, cls := "div-component", display.block, marginRight := "30px", 
              label(lbl, textAlign:="Left", /*marginLeft := "10px",*/ display.block), 
             props, txtComponent
      )
  }
the match throw an exception when the input receive a string of character like: d, 1a.
at this moment it works more less, but I think it need to do it correctly: "functionally and reactive-ly", :)
elyphas
@elyphas
the function cmpInput works as a wrapper over html inputs, then in case of number I need to handle more specifically then for this is the other function: cmpInputNumber.
the call to this function gives me a control with label and an input box:
cmpInputNumber("Ejercicio", hdlFiscalPeriod, VDomModifier(width:="35px", marginRight:="30px", textAlign:="center"),
              Some(VDomModifier(onChangingFiscalPeriod)))
elyphas
@elyphas
________________
|   Etiqueta    |
____________
|  inputBox  |
____________
elyphas
@elyphas
@busti ; I think this: onErrorHandle is what I need, what do You think?
moritz bust
@busti
My though was that calling Try.apply would always return a Success.
johannes karoff
@cornerman
Actually Try.apply can return either Success or Failure. Internally it wraps the code inside apply into a try catch.
johannes karoff
@cornerman
Instead of Try, I would let the observable handle the error. So you should be able to do something like: hdl.transformSubject[String](_.map(_.toInt).recover(_ => 0))(_.map(_.toString))
moritz bust
@busti
@cornerman Ah, sorry I did not know about that.
elyphas
@elyphas
@cornerman ; thank you
@busti ; thank you
elyphas
@elyphas
@cornerman ; sorry I can't make it work
this works fine but the rest don't
ver.foreach { x => println ( s"Estamos checando ********************** ##################### $x " ) }
hdl.transformSubject[String]{ y =>
                val ver = y.map { x =>
                  println ( s"Changos estamos probando esto &&&&&&  $x " )
                  val v = if (x == "") 0 else x.toInt
                  (v * 3)
                }.recover { ex =>
                  println ( s"Ocurrio un error ${ex.getMessage} " )
                  0
                }
                ver.foreach { x => println ( s"Estamos checando ********************** ##################### $x " ) }

                val v = y.map { x =>
                    println ( s"se va a convertir el tipo de dato. ******************** changos $x " )
                    if ( x == "" ) 0 else x.toInt
                  }
                  .recover { ex =>
                    println ( s"Ocurrio un error ${ex.getMessage} " )
                    0
                  }
                  v
                } {
                _.map { f: Int =>
                  println ( s" Convirtiendo número a texto ************************* $f  " )
                  if ( f <= 0 ) "" else f.toString
                }.recover ( _ => "" )
            }
any idea?
johannes karoff
@cornerman
@elyphas What exactly does not work?
elyphas
@elyphas

@cornerman ; Hi, with this code:

hdl.transformSubject[String]{ x =>
                  x.map(_.toInt).recover { _ => 0 }
              } {
                  _.map { x => if (x > 0 ) x.toString else "" }.recover ( _ => "" )
              },

I am trying to do this:
start my Handler.create[Int](0)
but when is 0 the input box must show empty string.
and if there is an error recover with 0 and input box show "".

elyphas
@elyphas
but it doesn't recover from itself
johannes karoff
@cornerman

but it doesn't recover from itself

what do you mean by that?

elyphas
@elyphas
@cornerman ; if I start the Handler with 0 then app doesn't work, or if the Handler start for example with 1 and I introduce some error like "1d" it is not pass throught recover
johannes karoff
@cornerman
@elyphas Do you connect to the returned handler? Because transform returns a Connectable that you need to subscribe to to make it work.
elyphas
@elyphas

@cornerman ; I am doing this:

value <-- hdl,
      onKeyUp.map { k =>
             val txt = k.currentTarget.asInstanceOf[html.Input]
              if ( txt.value == "" ) "" else txt.value
      } --> hdl,

with the handler returned.

johannes karoff
@cornerman
@elyphas Does it work? What is hdl?
elyphas
@elyphas
@cornerman , it doesnt work, hdl is my handler returned from transformation
johannes karoff
@cornerman
@elyphas Did you connect() the transformed handler?
elyphas
@elyphas
Not, I thought to subscribe to the event it would be enough
johannes karoff
@cornerman
Using transform on Observers sadly requires to connect to the transformed Handler. And it should be cancelled if the handler is not in use anymore.
elyphas
@elyphas
Ah ok, thank you
elyphas
@elyphas

@cornerman ; It works, but with the connectable I need to rethink my app design but I think is for better.

Thank you!

johannes karoff
@cornerman
@elyphas The connectable thingy is really not so great to handle and easy to forget. It would be great to find a better solution, but I do not know one :/
It is required for transforming the observer part.
If it is a handler that lives forever on the top-level of your app, you can just connect and never cancel.
Otherwise, you can use something like: div(managed(.....connect())) somewhere in your app.
elyphas
@elyphas
Ah ok, thank you
elyphas
@elyphas

hi, I am having trouble in a new virtualmachine with this:

sbt.librarymanagement.ResolveException: Error downloading com.github.outwatch.outwatch:outwatch-monix_sjs0.6_2.13:master-SNAPSHOT

seems that I need a specific commit I tried 61deece but didn't work
where can I find the commit for this?

johannes karoff
@cornerman
@elyphas We have updated to scalajs-1.0. So you need to use a specific commit for working with scalajs 0.6.x (e227ae0) or you upgrade your app to scalajs-1.x (master or 61deece). In general, it is better to depend on a specific commit - otherwise your build might break in the future.
elyphas
@elyphas
@cornerman , thank you
elyphas
@elyphas
hi
is there a way to know or to get the ip that is serving the files?
when the renderInto is run
elyphas
@elyphas
is this a right option: org.scalajs.dom.window.location.host?
johannes karoff
@cornerman
@elyphas yes window.location is your friend for this :)
elyphas
@elyphas
@cornerman ; thank you, :)
elyphas
@elyphas

any idea, please, about why this handlers:

  val hdlProveedor = Handler.create[String]
  val hdlRFCProvedor = Handler.create[String]

do not update its values.
in this observer:

  val updateIdAndDesdripProveedor = new Observer[Map[String, String]] {
       def onNext(elem: Map[String, String]): Unit = {
           val rfc = elem.getOrElse("id","")
           val prov = elem.getOrElse("descripcion","")
           Try {
               for {
                   hdlRFC <- hdlRFCProvedor
                   hdlProv <- hdlProveedor
               } yield {
                    hdlRFC.onNext(rfc)
                    hdlProv.onNext(prov)
               }
          } match {
             case Success(value) => value
             case Failure(exception) => alert("Hubo un error from FrmReportMaker " + exception.getMessage)
          }
       }
       def onError(ex: Throwable): Unit = { alert(ex.printStackTrace.toString) }
       def onComplete(): Unit = println("O completed -- ")
   }

 def render = colibri.Observable(renderRaw.unsafeRunSync)

  def renderRaw = 
for {
       proveedor <- hdlProveedor
       rfcProveedor <- hdlRFCProvedor
  } yield {
      div (
        div(cls := "groupControls",
          cmpInput("R.F.C. Proveedor", rfcProveedor, stylesMedium, None),
          cmpInput("Proveedor", proveedor, stylesXLarger, onInputProveedor),
          gridCatalogProveedor.gridCatalogSearchResult
        )
     )
  }
johannes karoff
@cornerman
@elyphas You are evaluating the IO returned by Handler.create multiple times and therefore always get a different Handler. You create a new handler in each onNext call and then create another one in renderRaw. You need to map over the handler once around both updateIdAndDesdripProveedor and renderRaw.
elyphas
@elyphas
@cornerman ; ah, thank you!