I am trying to serialize a subscription to send over a network. I am using Scala and doing something like this:
observable.materialize.subscribe{ n : Notification => sendToNetwork(n)}
However, I get errors:
java.io.NotSerializableException: rx.lang.scala.Notification$OnNext
(To be precise, I use Akka and try to send notifications to the remote player. But I think this problem is more general than this).
It seems like he refuses to serialize the class OnNext, which is actually a subclass Notification, which is the inner class of the companion object rx.lang.scala.Notification:
http://rxscala.imtqy.com/scaladoc/#rx.lang.scala.Notification $$ OnNext
... and I think I saw somewhere in the Java documentation that it is not possible to serialize internal non-static classes.
How do I get it right? If so, is this a limitation of the rx-java class hierarchy? Or is there some way around this and serialize Notifications?
source
share