smutbook:classes:persistence:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |
smutbook:classes:persistence:start [2023/08/07 15:50] – lee | smutbook:classes:persistence:start [2023/08/07 15:57] (current) – lee |
---|
These three layers are implemented transparently by returning a Proxy object from the PersistentObject constructor. The Proxy's handler intercepts all property accesses to the PersistentObject and correctly routes them through the layered data levels. | These three layers are implemented transparently by returning a Proxy object from the PersistentObject constructor. The Proxy's handler intercepts all property accesses to the PersistentObject and correctly routes them through the layered data levels. |
| |
This handler also replaces all references to PersistentObjects stored within Sugarcube's state history with a placeholder object that tracks the real PersistentObject's 'id' field, and then reinstantiates the real PersistentObject when it is fetched back from the Sugarcube datastore. This allows for circular graphs of PersistentObjects to be stored within Sugarcube's state history without causing a covfefe. You still can't have circular graphs of non-PersistentObjects, but as long as there is a PersistentObject somewhere in the graph that keeps the circle from linking back to itself, things should work. It's not the most efficient way to do things, but I think it's the best way short of patching SugarCube itself. | This handler also replaces all references to PersistentObjects stored within Sugarcube's state history with a placeholder object that tracks the real PersistentObject's 'id' field, and then reinstantiates the real PersistentObject when it is fetched back from the Sugarcube datastore. This allows for circular graphs of PersistentObjects to be stored within Sugarcube's state history without causing a covfefe. You still can't have circular graphs of non-PersistentObjects, but as long as there is a PersistentObject somewhere in the graph that keeps the circle from linking back to itself, things should kinda work, maybe. It's not the most efficient way to do things, but I think it's the best way short of patching SugarCube itself. |
| |
Please look at the [[Tutorial]] for more details. This implementation works decently well, but there are some gotchas to look out for that are sort of hacked around, particularly in the constructors of subclasses. | Please look at the [[Tutorial]] for more details. This implementation works decently well, but there are some gotchas to look out for that are sort of hacked around, particularly in the constructors of subclasses. |
| |
smutbook/classes/persistence/start.1691448634.txt.gz · Last modified: 2023/08/07 15:50 by lee