## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• Oct 15 11:25

mathieuleclaire on master

Update sbt-scalajs, scalajs-com… Merge pull request #141 from sc… (compare)

• Oct 15 11:25
mathieuleclaire closed #141
• Oct 15 11:15
scala-steward opened #141
• Sep 28 18:17
ochrons closed #140
• Sep 28 18:17
ochrons commented #140
• Sep 22 13:24
manosntoulias edited #140
• Sep 22 13:24
manosntoulias opened #140
• Sep 08 23:55
scala-steward opened #139
• Aug 30 06:44
scala-steward opened #138
• Jul 02 02:00
scala-steward opened #137
• Jun 28 01:08
scala-steward opened #136
• Jun 26 01:22
phb opened #135
• Jun 09 00:48
japgolly commented #127
• Jun 08 20:58
scala-steward opened #134
• Jun 08 20:58
scala-steward opened #133
• Jun 08 20:58
scala-steward opened #132
• Jun 08 20:58
scala-steward opened #131
• Jun 08 20:58
scala-steward opened #130
• Jun 08 06:11
ochrons closed #127
• Jun 08 06:11
ochrons commented #127
Tushar Mathur
@tusharmath
case class Point(x: Int, y: Int)

val p = Point(5, 10)
val points = Vector(p, p, p, p)
val bb = Pickle.intoBytes(points)
.
.
val newPoints = Unpickle[Vector[Point]].fromBytes(bb)
this example from gitbook doesn't work
Unpickle does not take type parameters
How else do we use it ?
Rok Kralj
@strelec
The error is only in the IDE, not when compiling with scalac
Rok Kralj
@strelec
@ochrons Why is boopickle encoding a zero in front of every object
For example Vector(Point(1,2), Point(3,4), Point(5,6)) serializes into Array(3, 0, 1, 2, 0, 3, 4, 0, 5, 6)
Tushar Mathur
@tusharmath
@strelec yeah got that eventually.
but why is that ?
how can i fix it?
Otto Chrons
@ochrons
@strelec because it uses that to encode things like null and also for references to the same object
Marc Grue
@marcgrue

Struggled to find a way to pickle bytes running throuch a WebSocket in a Play Scala-js project and finally got it working. While I was at it I made my whole autowiring setup more generic so that I only have to configure the moving parts when adding a new api for instance.

Having a generic interface also allows to avoid messing around with websocket callbacks and instead use the exact same api as we do when using ajax:

// autowire websocket wire handle
object fooWireWS extends AutowireWebSocket[FooApi]("foo")

// Make type-safe api calls throuch websocket...
fooWireWS().incr(curNumber).call().foreach { n =>
println("got an incremented number from the server via WebSocket: " + n)
}

Long story short - made a minimal sample project with all generic autowire plumbing separated out into a few generic util classes. Pretty neat me thinks. Hope this will be useful for others. Let me know if you have any comments or suggestions for improvements.

PS: You'll also find an ajax vs websocket performance test, yay...

Rok Kralj
@strelec
@ochrons Thanks Otto! It does seem a bit wasteful, we could enforce acyclic and non-null structures. Protocol buffers use this extra byte to provide backwards and forwards compatibility.
Rok Kralj
@strelec
For the ScalaJS 1.0.0 release are you waiting for a pull request?
Tushar Mathur
@tusharmath

Unknown object coding: 78

How should I debug this error?

Trond Bjerkestrand
@strelec I tried to do an update to 1.0.0, but ran into some issues with UintArray8 and IntArray8 tbje/boopickle@f9aaf12
moritz bust
@busti
Is it possible idea to unpickle an object into different types extending the same base class on the back and frontend? If so is it a good idea?
I remember reading something about that in the documentation, but that was over a year ago and I cannot find it anymore.
Otto Chrons
@ochrons
well as long as they are compatible on the "protocol level"
like you can encode a List[Int] and decode it as Vector[Int] no problem
or have a case class with differently named members, but of the same type
Marc Grue
@marcgrue
Have been working on updating Lihaoyi's autowire lib to version 0.3.2 with @mathieuleclaire (see PR). The suzaku-io/boopickle#126 would allow us to have the boopickle test working with both Scala 2.12 and 2.13. So, anytime you publish a 1.3.3, @ochrons, we'll publish autowire 0.3.3 with a working boopickle example...
moritz bust
@busti
@ochrons Sorry I didn't get back to your reply in time, it was very helpful, thanks a lot.
Walter Chang
@weihsiu
guys, i am in a bit of a pickle here (no pun intended). i am getting java.nio.BufferOverflowException when i do Pickle.intoBytes() in scalajs. the weird thing is that for the first 4 calls, there were no trouble, it's not until the 5th call to intoBytes() would the exception get thrown. i know there are pooling stuff going on in the BufferProvider but from the outside, the intoBytes() call should be pure. so the BufferOverflowException really puzzles me.
Walter Chang
@weihsiu
found the bug: i guess reusing PickleState isn't a great idea after all ;)
Otto Chrons
@ochrons
yeah, it's a stateful thing that you can use to build a larger pickle :)
Carlos Quiroz
@cquiroz
Hi, it seems the release task on boopickle is now working, could we do a tag to test the release?
Otto Chrons
@ochrons
Carlos Quiroz
@cquiroz
I don’t have committer rights on boopickle
I think
Otto Chrons
@ochrons
ok, got the 1.3.3 publish done via Github Actions
@cquiroz if you want to create a PR to use tag as version instead of manual override (like you did in Diode), that would be great :)
Carlos Quiroz
@cquiroz
Sure, I want to add both diode and boopickle to scala-steward, Would that be ok?
Otto Chrons
@ochrons
sure!
you can use the PickleState to deserialize multiple things from the same byte buffer (assuming they're all fully there)
I could read all data by calling tryFromBytes until it fails so works like a charm. But maybe your suggestion will be cleaner, is there an example somewhere ?