Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
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
Otto Chrons
@ochrons
you would have to describe the arguments some other way, like with a case class
or by building a chain of classes with apply functions returning the next class
moritz bust
@busti
Yeah, I am using case classes right now to do this, but it makes things really verbose.
@ochrons Thanks again :)
moritz bust
@busti
To give a bit of context, my environment is very similar to DIODE, but I have a hard requirement on being able to serialize actions. The idea is to have actions defined as def (a: Int, b: String) = Action { state => state.copy(foo = a, bar = b) }.
I guess that I could make this work with a macro, which generates a serialisation method and adds it to the Action object.
Otto Chrons
@ochrons
use Free Monad :wink:
moritz bust
@busti
@ochrons I have read the docs of cats Free[_] for the past hour or so.
I have looked at them before, but I am not quite sure what you intend. Is your suggestion to implement Actions as an algebra and have two separate compilers, one for serialization and one for state mutation?
Otto Chrons
@ochrons
well, Free is able to capture the Actions and then you can serialize it easily
since it's just a bunch of case classes
Rok Kralj
@strelec
I have two questions:
  1. Have there been any changes that could affect the binary format since 1.3.0?
  1. Do we consider scala.js 1.0.0 stable enough to push a boopickle release for it?
Dennis
@dennis4b_twitter
Hi! Is there a clever way to find out which types are automatically derived the most times (ie duplications that would benefit from explicitly creating the pickler in a central place so that its macro is generated only once). Because I am using sloth for client-server communications I need to use auto-derivation as the sloth macros generate case classes that I could otherwise not serialize.
Dennis
@dennis4b_twitter
aha its in the docs, sorry, thought I did read everything .. great!
Otto Chrons
@ochrons
should be no obstacles publishing Boopickle for 1.0.0
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
@tbjerkes_twitter
@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
sure, go ahead!
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!
Vladimir Bodnartchouk
@Fraer
Hello, i'm sending serialized entities from backend as a stream one by one and not as Seq of entities, so on reception only the first one gets deserialized (unpickled), maybe there is a way to continue consuming next entity until there is nothing left in the ByteBuffer? Or maybe it is possible to inject separators on the fly and once all data is received deserialize it as a Seq of entities?
Otto Chrons
@ochrons
you can use the PickleState to deserialize multiple things from the same byte buffer (assuming they're all fully there)
Vladimir Bodnartchouk
@Fraer
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 ?