Skip to content
Discussion options

You must be logged in to vote

Our general recommendation is to copy editable records in local @State that can be bound, and then update explicitly depending on your needs. You could do any one or more of the following:

  1. You mentioned an explicit "Save" step, which could be executed alongside dismissal
  2. You could save when the text editor loses focus.
  3. You could save when the app is backgrounded.
  4. You could add a task view modifier that debounces saves to the database based off the hash identity of the record:
    .task(id: record) {
      try await Task.sleep(for: .seconds(1))
      try await saveRecord()
    }
    
  5. You could add an onDisappear to always save when the view goes away.

These are just a few examples, but there are many more …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by bennowo
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants