Skip to content

Serialization

frcroth edited this page May 11, 2021 · 2 revisions

What gets serialized

  • Morphs in the world get serialized, by serializing their properties
  • To save custom morph properties, they need to be defined in the properties getter. More info

What happens when saving

  • Saving creates a snapshot
  • The serializer dissolves circular dependencies
  • When serializing was successful, lively tries to deserialize the snapshot
  • Only if this works saving was successful

How to make custom behavior while saving

  • one can use methods like __after_deserialize__ and similar as hooks (_additionaly_serialize__)
  • Use addFn('propertyName' , propertyValue) to add additional properties, this will dissolve circular dependencies
  • just adding snapshot.prop.propname = propValue will work but not check whether there are circular dependencies

Notes

Some properties can not be saved

  • WeakMaps, WeakRefs
  • use the hooks to make custom data structures to save them