HeapsIO / hxbit

Haxe Binary serialization and network synchronization library
155 stars 30 forks source link

Unserialize immediately after Serialize does not maintain the same object? #19

Closed Coderah closed 7 years ago

Coderah commented 7 years ago

if you were to serialize something then immediately unserialize it, hxbit will create a new instance every time, it even loses references to any unserialized object before it. Is there a design reason for this?

My use-case requires updating an existing object in memory via unserializing from bytes obtained elsewhere.

in short, if I serialize an object with __uid = 4 then unserialize the bytes returned i'd expect it to update the original object in memory, instead I'm returned a new object with the same __uid = 4

ncannasse commented 7 years ago

I don't think that should be default behavior, but you might be able to do it by overriding the corresponding methods and reusing a cache in Serializer.