Replies: 1 comment 3 replies
-
|
Hi @gerfarfel, there just is no good way to achieve what you want when using value types, regardless of using TCA/SQLiteData or not. What you want is the ability to have data stored externally, for the data to be fetched for a feature in a collection, and then to have rows in a list hold each element from the collection and have their mutations be connected to the parent feature and external data source. There's no way to package up all that magic in value types. That's something reference types can do of course, but then that comes with a bunch of other downsides. But also, we feel that it is rarely ever needed to actually break features down along the boundaries of elements in a collection. We do provide the tools for this ( |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a follow-up to #260 (and #47) on the topic of using SQLiteData with TCA. My question has to do with how to bridge between parent and child reducers. I know that this is essentially the same question that was asked in #260, but I'd like to revisit it in a more generalized context. Actually, I'm hoping that I've misunderstood something about the answer to that question, because it seems to imply that one of TCA's core features (composition) isn't fully compatible with SQLiteData.
In the simple example below, the parent reducer (
RemindersDetail) is fetching an array ofReminders from the database. The child reducer (ReminderRow) holds mutable transient variables in addition to data from the database. The question is how to generate the array of child states (reminderRows) in the parent state. It can't be generated via a custom database fetch, because it contains mutable transient data, and generating it through a computed property means that new child state will be created every time it's accessed, which can also be highly problematic.The advice for the specific case discussed in #260 (as I understand it) was to subsume the child state directly into the parent. This approach can work, but it takes TCA's primary superpower – composition – off the table. If SQLiteData imposes significant restrictions on how data can be modeled with TCA, then that's a significant downside to using the two libraries together.
My current approach (which also has obvious downsides) has been to not hold
@Fetchdata directly in my reducer state, but rather to use SQLiteData as a back-end for handling database transactions. I'd love to know if I've misunderstood something here, or if anyone has come up with a better approach.As a final comment, I'd love to see more examples and discussion of how to use SQLiteData and TCA together. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions