These are chat archives for chandu0101/scalajs-react-components

21st
Aug 2015
Øyvind Raddum Berg
@oyvindberg
Aug 21 2015 01:55
right, ive had more than a look at it. porting the pure scala components was easy, just a bit of manual work
but when it comes to the wrapped javascript components i could use your opinion on how to do it
essentially, if the exposed scala interface has functions like onChange:U[(JDate, JDate) => Callback] = js.undefined
(U = js.UndefOr)
we need to rewrite the function like this
  def updateDynamicF2[T1, T2, R](s: String)(uf: U[(T1, T2) => CallbackTo[R]]): Unit = {
    uf.foreach{ f ⇒
      val jsf: js.Function2[T1, T2, R] = (t1: T1, t2: T2) ⇒ f(t1, t2).runNow()
      p.updateDynamic(s)(jsf)
    }
  }
ie the runNow()
Øyvind Raddum Berg
@oyvindberg
Aug 21 2015 02:01
and to do that in a typesafe way, I was thinking about wrapping js.Dynamic.literal in something that the wrappers would call to set all the values.
and well, it's a mess since everything is convertable to js.Any
any thoughts @chandu0101 ?
ignore my comment i didnt read u r first post :( , reading now ..
Øyvind Raddum Berg
@oyvindberg
Aug 21 2015 02:05
right, i suppose you could solve it with a macro, but if it could be generated correctly in the first place, that would be best
Chandra Sekhar Kode
@chandu0101
Aug 21 2015 02:13
not sure i understand implementation there ( because i don’t know what runNow )
can you please explain me in detail .. what exactly updateDynamicF2 is doing ..
Øyvind Raddum Berg
@oyvindberg
Aug 21 2015 02:13
think unsafePerformIO
for scalaz.IO
Chandra Sekhar Kode
@chandu0101
Aug 21 2015 02:14
ah i didn’t know scalaZ too , in general what it solves ?
Øyvind Raddum Berg
@oyvindberg
Aug 21 2015 02:15
ah right
so the new Callback is essentially a wrapped function
runNow() runs it
if you dont make sure to run it, the callback will not be run
Øyvind Raddum Berg
@oyvindberg
Aug 21 2015 02:21
anyways, im off to bed for now
Chandra Sekhar Kode
@chandu0101
Aug 21 2015 02:21
if it’s going to add more safety go a head and add it :)
my little brain may need more time to understand it ;)
gn
Øyvind Raddum Berg
@oyvindberg
Aug 21 2015 15:22
yeah right
i gave it a shot here elacin/scalajs-react-components@610b2bb
pretty much at the top
done it for the whole codebase except for the bootstrap part
seems to work well :)
Chandra Sekhar Kode
@chandu0101
Aug 21 2015 21:21
excellent :+1: