You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Many use upickle is to enable structured cloning ( eg. scalajs-rx-idb, others to pass objects between WebWorkers, etc... ).
But the way upickle is written it is
not efficient as some types of objects can be cloned just because they extend js.Any without needing to be serialised by upickle ( see @sjrd's comment on the structured cloning thread )
does not support Opaque Objects - as these are exactly objects that cannot be transformed the way upickle does into simple basic json types.
Writing seems relatively straightforward.
The problem comes from reading JS Objects. To do that correctly one would need to know what the objects were going to be serialised to first. ( see note in json.readJs function ): after all one may not want to walk through an object that is going to be mapped to a class extending js.Any, since it can just be transformed to that object with an jsobj.asInstanceOf[ScalaClass]
This is for example how scalajs-rx-idb uses that function.
It passes it to readJS that then constructs the object. It seems that what would be needed would be a merger of the two functions, so upickle's Types.readJs[K] could make the decision as to wether it should bother mapping the object at all...
The text was updated successfully, but these errors were encountered:
Many use upickle is to enable structured cloning ( eg. scalajs-rx-idb, others to pass objects between WebWorkers, etc... ).
But the way upickle is written it is
js.Any
without needing to be serialised by upickle ( see @sjrd's comment on the structured cloning thread )I actually tried to see if I could make some minor changes to
upickle
for this to work with PR 122: enable non serializable objects.Writing seems relatively straightforward.
The problem comes from reading JS Objects. To do that correctly one would need to know what the objects were going to be serialised to first. ( see note in json.readJs function ): after all one may not want to walk through an object that is going to be mapped to a class extending
js.Any
, since it can just be transformed to that object with anjsobj.asInstanceOf[ScalaClass]
This is for example how scalajs-rx-idb uses that function.
It passes it to
readJS
that then constructs the object. It seems that what would be needed would be a merger of the two functions, so upickle'sTypes.readJs[K]
could make the decision as to wether it should bother mapping the object at all...The text was updated successfully, but these errors were encountered: