Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: SerializableType

[24:7] extends: FxObj

Wraps an AussomSerializableType (implementation of FXGL's SerializableType interface) so Aussom code can supply persistence behaviour to APIs that take a SerializableType. The two on* methods register callbacks for write and read; each receives a Bundle wrapper. Example: st = new SerializableType(); st.onWrite(::saveMyState); st.onRead(::loadMyState); public saveMyState(bundle) { bundle.put("hp", 42); } public loadMyState(bundle) { hp = bundle.get("hp"); }

Methods

  • SerializableType ()

    Creates a new SerializableType bridge ready to receive onWrite / onRead callbacks.

  • adopt (object Ajo)

    Wraps an existing AussomSerializableType AussomJavaObject.

    • @p Ajo is an AussomJavaObject around an AussomSerializableType.
    • @r A new wrapper.
  • onWrite (callback Cb)

    Registers the write callback. The callback receives a Bundle wrapper and stores state in it.

    • @p Cb is a callback (bundle) -> any.
    • @r this object
  • onRead (callback Cb)

    Registers the read callback. The callback receives a Bundle wrapper and restores state from it.

    • @p Cb is a callback (bundle) -> any.
    • @r this object
  • write (object BundleObj)

    Triggers the write callback with the supplied Bundle.

  • read (object BundleObj)

    Triggers the read callback with the supplied Bundle.