Skip to content

Serialization

linusha edited this page May 8, 2021 · 2 revisions

What gets serialized

  • one needs to define properties to have them saved

What happens when saving

  • saving creates a snapshot
  • the serializer dissolves circular dependencies
  • when serializing was successful, lively tries to deserialize the snapshot onces
  • only if this works saving was successful
  • Be aware of adding objects to the opened world!!

How to make custom behavior while saving

  • some objects can not be saved by default
  • for example weak maps
  • you can use methods like __after_deserialize__ and similar as hooks
  • if you want to save something circular like a morph structure in the snapshot customized use addFn('propertyName' , propertyValue) this will have a look on the dependencies and will dissolve the circular dependencies if necessary
  • just adding snapshot.prop.propname = propValue will work but not check whether there are circular dependencies
Clone this wiki locally