Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 23 09:24
    @sjrd banned @yensaoxuan_twitter
  • Apr 18 19:06
    @sjrd banned @Amitgup48798297_twitter
  • Mar 29 07:47
    @sjrd banned @quangs
  • Jan 23 06:34
    @sjrd banned @Rebeka58_gitlab
  • Jun 08 2020 20:43
    @sjrd banned @sw7240614
  • Sep 29 2019 08:35
    @sjrd banned @8bitpitRBX_twitter
  • May 23 2019 13:44
    @sjrd banned @BIGCRYPTO001_gitlab
  • May 01 2019 14:31
    @sjrd banned @Certificates1_gitlab
  • Apr 22 2019 15:31
    @sjrd banned @lerbatax
  • Jan 31 2019 23:04
    sjrd commented #3555
  • Jan 31 2019 22:56
    sjrd review_requested #3555
  • Jan 31 2019 22:56
    sjrd opened #3555
  • Jan 31 2019 21:06

    sjrd on 0.6.x

    Remove dead code: specific coll… Adapt the signature of `js.Arra… Merge pull request #3554 from s… (compare)

  • Jan 31 2019 21:06
    sjrd closed #3554
  • Jan 31 2019 20:54
    erikvanoosten commented #2665
  • Jan 31 2019 16:33
    sjrd commented #3538
  • Jan 31 2019 15:54

    sjrd on master

    Fix analyzer cycle detection to… Add toString methods to analyze… Do not provide linked ClassInfo… and 1 more (compare)

  • Jan 31 2019 15:54
    sjrd closed #3552
  • Jan 31 2019 15:54

    sjrd on master

    Remove Logger.success It is un… Make level helpers final Clean-up ScalaConsoleLogger cod… and 1 more (compare)

  • Jan 31 2019 15:54
    sjrd closed #3553
Tobias Schlatter
@gzm0
You'll need to put these into the platform specific source directories. But all your other code, can now simply use Platform.MySeq.
(-ish of course, you'll probably also need to construct MySeqs etc. but the basic principle stands)
moritz bust
@busti
Nice, yeah that will probably work, thanks :)

There used to be a library that specifically claimed to be the fastest dom rendering lib in sjs, but I cannot remember the name and I also cannot find it.
Does anyone remember a library like that?
Li Haoyi
@lihaoyi
dunno about fastest but scalatags is pretty fast and convenient
works great rendering vdom nodes or strings too
k0ala
@k0ala
Hi all, Scala.js noob here (and webdev noob as well - I do know Scala though). I would be glad for guidance on the following. I have an AWS Cognito login which returns a JWT token. Based on what I've read about JWT tokens, here is how I think it should work: 1) user completes Cognito login, receives a token. 2) Scala.JS saves the token and adds it to every request header going forward. 3) server validates the token at every request. Does that sound reasonable? Or am I heading in the wrong direction? And which ScalaJS methods can I use on the client side? Cheers
Antoine Doeraene
@sherpal
Yes it sounds reasonable. The JWT must be sent in a header for all requests to the server. For how to do it, it mostly depends what library you are using to make your http calls from your frontend. This could be: plain old XMLHttpRequest, the less old JS fetch function (in both these cases, refer to the excellent MDN docs), sttp library (in that case, refer to their docs) or perhaps something else (the last one I know of is roshttp
k0ala
@k0ala
@sherpal thank you for these pointers. I will try with XMLHttpRequest first, since my goal is to understand how it all works.
any advice on how to store the token on the client side?
Antoine Doeraene
@sherpal
If you want to store it for a long time, you can use the LocalStorage (dom.window.localStorage.setItem(someKey, tokenValue)). Otherwise just keep it in memory somewhere
Of course you could also decide that your backend puts it in a cookie, then you have nothing to do
k0ala
@k0ala
@sherpal aha, I am using cask, so if I understand correctly I should be looking at cask for putting it in a cookie
moritz bust
@busti
@lihaoyi scalatags is a great lib for sure. I am asking because the library I am looking for did some sort of magic to achieve its speeds and I would like to implement the same for outwatch if the principle can be ported.
Jason Pickens
@steinybot:matrix.org
[m]
Is there no Evidence[String, js.Any] or any of the other values that are implicitly js.Any (by casting)?
Sébastien Doeraene
@sjrd
No there isn't. That wouldn't model union types accurately, and so would break in Scala 3 anyway.
Jason Pickens
@steinybot:matrix.org
[m]
Why is that?
Seems to work fine:
val a: AnyRef | Unit = "Hello"
println(a)
val b: AnyRef | Unit = ()
println(b)
val c: String | Unit = "Hello"
val d: AnyRef | Unit = c
println(d)
Sébastien Doeraene
@sjrd
println takes Any, so that works. Things that take js.Any arguments should be quite rare, as there is virtually no use case to use js.Any over Any (other than in an extends clause).
Jason Pickens
@steinybot:matrix.org
[m]
ScalablyTyped will convert value?: any; to value: UndefOf[js.Any]. Should I raise a bug with ST then?
Jason Pickens
@steinybot:matrix.org
[m]

I think I see what you mean by it not working in Scala 3:

import scala.language.implicitConversions

trait JsAny extends scala.AnyRef

object JsAny {
  given Conversion[String, JsAny] = _.asInstanceOf[JsAny]
}

val a: String | Unit = "Hello"

val b: JsAny | Unit = "Goodbye"

//Found:    (Playground.a : String | Unit)
//Required: Playground.JsAny | Unit
//val c: JsAny | Unit = a

val d: JsAny | Unit = a match
  case s: String => s
  case () => ()

In practice you can use a String value in place of a js.Any and a js.Any | Unit because it will be converted implicitly but a String is not a subtype of js.Any and so String | Unit is not a jsAny | Unit either. That's a bit awkward.

Jason Pickens
@steinybot:matrix.org
[m]

:point_up: Edit: I think I see what you mean by it not working in Scala 3:

import scala.language.implicitConversions

trait JsAny extends scala.AnyRef

object JsAny {
  given Conversion[String, JsAny] = _.asInstanceOf[JsAny]
}

val a: String | Unit = "Hello"

val b: JsAny | Unit = "Goodbye"

//Found:    (Playground.a : String | Unit)
//Required: Playground.JsAny | Unit
//val c: JsAny | Unit = a

val d: JsAny | Unit = a match
  case s: String => s
  case () => ()

In practice you can use a String value in place of a js.Any and a js.Any | Unit because it will be converted implicitly but a String is not a subtype of js.Any and so String | Unit is not a jsAny | Unit either. That's a bit awkward.

QP
@theqp
is there a way to run Closure Compiler optimizations without renamings?
Sébastien Doeraene
@sjrd
The Closure optimizations are mostly renaming.
And no, there is no way.
You're not supposed to inspect or rely on names anyway.
Even fastOpt can change the names as it pleases (and we actually do sometimes).
bblfish
@bblfish:matrix.org
[m]

I am just getting going with scala.js and noticed that if I add

scalacOptions := Seq( 
...
)

to build.sbt then run fails and does not produce "Hello World"

I am using 3.1.0-RC2 but the same happend with 3.0.1

sometimes I have to add an option such as "-Yexplicit-nulls"
This i with the minimal setup given in the first page of the documentation https://www.scala-js.org/doc/tutorial/basic/
bblfish
@bblfish:matrix.org
[m]
I got some help in Discord. I needed to use ++= rather than :=
scalacOptions ++= Seq(...)
Hanns Holger Rutz
@Sciss
How come API is not compatible between DOM 1.1.0 and 1.2.0? In 1.1.0, I had IDBRequest.onerror: js.Function1[ErrorEvent, _], and in 1.2.0 it's just js.Function1[Event, _], breaking source compatibility.
also dom.window.indexedDB suddenly returns js.UndefOr[IDBFactory] instead of IDBFactory
Hanns Holger Rutz
@Sciss

If I do this

    req.onerror = {
      case e: dom.ErrorEvent => // XXX TODO: why this guarantee broke in scalajs DOM 1.2.0 ?
        pr.failure(failure(e))

      case _ =>
        pr.failure(new IOException(req.error.message))
    }

I just get isInstanceOf[org.scalajs.dom.raw.ErrorEvent] not supported because it is a JS trait. So I have to furthe rewrite an existing library? :(

do I just cast asInstanceOf[ErrorEvent], or ... ?
Sébastien Doeraene
@sjrd
Minor releases preserve binary compatibility, but not source compatibility.
If guarantees are broken, it's normally because the DOM doesn't actually give that guarantee.
You can cast if you don't want to change your code.
Hanns Holger Rutz
@Sciss
but what is the reason that ErrorEvent was changed to less specific Event?
johnhungerford
@johnhungerford
It looks like the js api passes an Event and not an ErrorEvent so this might just be a correction: https://developer.mozilla.org/en-US/docs/Web/API/IDBRequest/onerror
I ran into a similar issue with Xhr
doofin
@doofin
Hi guys what is the idiomatic way to use union types a | b in scala (js) 2.12? Seems that a| b match {case a=>...} doesn't work and I can't find many info about this issue.
Sébastien Doeraene
@sjrd
The idiomatic way is not to use it except when interoperating with JavaScript libraries. ;)
If you really have to match on it, use (x: Any) match { case ... }
doofin
@doofin
Thanks,I tried that case User => works but if I use sth likecase x:User => then it will complain : not supported because it is a JS trait
Sébastien Doeraene
@sjrd
If the type you want to match against is an interface, then you indeed cannot type-test for it. That's independent of the union type, though.
In that case you have to use ad hoc logic to identify in which case you are, then cast.
doofin
@doofin
I guess the problem is that the type is a object object User {} rather than class or trait.so currently I can only force cast with .asInstanceOf[User] then maybe add a Try around it
Hanns Holger Rutz
@Sciss
@johnhungerford thanks for checking. Then I should change my code to also just rely on req.error for reporting.
johnhungerford
@johnhungerford
Yeah thats what it looks like to me