Contents

apply(snapshot:previous:)

Applies a loaded snapshot to the document model.

Declaration

@MainActor func apply(snapshot: sending Self.Reader.Snapshot, previous: sending Self.Reader.Snapshot?) async throws

Parameters

  • snapshot:

    The content loaded from disk.

  • previous:

    The previously loaded snapshot, or nil on the first read. Use it to apply incremental updates.

Discussion

SwiftUI calls this on the main actor after the reader’s read(from:progress:) completes. Update your model properties here. Keep this method lightweight — all deserialization should happen in the reader.

See Also

Reading a document