Hooking into the Save State

From Beerplop
Revision as of 12:07, 19 July 2019 by Wol-soft (talk | contribs) (Created page with "To create an entry in the save state a GamePersistor object is required. Using the method registerModule($key, $saveCallback, $loadCallback) of the save state a new entry can...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

To create an entry in the save state a GamePersistor object is required. Using the method registerModule($key, $saveCallback, $loadCallback) of the save state a new entry can be added.

The $key must be a unique key for the module. The $saveCallback must return a serializable value. The $loadCallback will either get the deserialized value which was stored before or won't be called if no entry is present for the module in the current save state.

An example integration may look like: