Journal App Part 13 | Save & Retrieve with Dependency Injection and Repositories

Поділитися
Вставка
  • Опубліковано 27 гру 2024

КОМЕНТАРІ • 4

  • @tomma5o
    @tomma5o 8 днів тому

    As always, this is a really clear and useful video!
    I have a question: you used two tasks one attached to the mainContent and one to the sheet.
    Maybe it’s just me, but I’d prefer to keep the data fetching closer to the sheetContentView. That way, if there are multiple sheets, the data fetching remains near the sheet that’s using it.
    There are ways to do it?

    • @iOScribbler
      @iOScribbler  8 днів тому +1

      Hi! Thank you for your support. Both task modifiers are attached to the mainContentView. The only difference is that the block inside the one with the id will be triggered only when that id is true(hence the guard statement). The one without id for data fetching will be triggered everytime the view appears. I hope that is clear.

    • @tomma5o
      @tomma5o 8 днів тому

      @@iOScribbler yep is clear, but let's suppose we have 10 sheet in the same view, i;ll need to have 10 task with 10 @state?
      Hope the question is clear :)

    • @iOScribbler
      @iOScribbler  8 днів тому

      @@tomma5o I see now. Well when you use task(id) is really a matter of preference. But yeah in this case it would have been cleaner to place that task for saving, attached to the subview that is the sheetContentView inside the extension. So in that way no matter how many sheets you have they are split across those subviews and the code would be easier to read. Great insight!