Skip to content

0.38.0

Latest

Choose a tag to compare

@ZacSweers ZacSweers released this 26 Aug 17:12
· 9 commits to main since this release

Screen and PopResult are no longer Parcelable

Screen and PopResult no longer extend Parcelable on Android. Apps upgrading to this release should choose the persistence strategy that fits each type

  • Already using kotlinx-serialization?

    • Keep the existing SerializableCircuitSaver or ReflectiveSerializableCircuitSaver setup. Remove @Parcelize, and use Screen or PopResult directly instead of the Parcelable marker interfaces.
  • Keep Android Parcelable persistence?

    • Retain @Parcelize and change the type to implement ParcelableScreen or ParcelablePopResult. The registry-backed default saver accepts these types on Android.
  • Migrate gradually?

    • Put the serializing saver first and retain the registry-backed saver as a fallback for Parcelable types:

      val circuit =
        Circuit.Builder()
          .setCircuitSaver { fallbackSaver ->
            serializableSaver + fallbackSaver
          }
          .build()
  • Do not persist navigation state?

    • Configure CircuitSaver.NoOp. Restored stacks start again from their initial value.

See Saving navigation state for complete setup and migration examples.

Saving an unsupported value now fails instead of silently dropping it. To intentionally drop values that no earlier saver supports, append CircuitSaver.Dropping { value -> ... } to the saver chain. Use CircuitSaver.NoOp as the final saver when dropped values do not need to be reported.

New

  • rememberDefaultCircuitSaver() creates a saver backed by the current Compose SaveableStateRegistry. CircuitCompositionLocals(circuit) uses it automatically when no static or inherited saver is available.
  • Combine CircuitSaver instances with +. Savers are tried from left to right, and the first saver that supports a value owns the save or restore operation.
  • Circuit.Builder.setCircuitSaver { fallbackSaver -> ... } combines an app saver with the saver inherited from the composition or created from its registry.
  • Custom savers can override canSave and canRestore to participate in a composite.

Removed

  • Removed DefaultCircuitSaver. CircuitCompositionLocals(circuit) now creates a registry-backed saver when needed. Call rememberDefaultCircuitSaver() when a saver must be passed explicitly.
  • Removed the deprecated companion Saver properties from SaveableBackStack and SaveableNavStack. Use the Saver(CircuitSaver) functions.

Fixed

  • Fixed R8 failures in apps using @CircuitSerializable or @CircuitInject without Hilt on the runtime classpath.

What's Changed

Full Changelog: 0.37.1...0.38.0