apply
functions returning the next class
def (a: Int, b: String) = Action { state => state.copy(foo = a, bar = b) }
.Action
object.
Unpickle does not take type parameters
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...
List[Int]
and decode it as Vector[Int]
no problem