Basic guidance on how to use with TCA #47
-
Thanks so much for the library, already using it in a prototype and loving it. I'm having trouble figuring out how I would integrate this library and approach with TCA. I'm certain it's straightforward to do so, but for some reason the mental model of how the pieces would fit together just won't click for me. I looked for a case study involving TCA, but don't see any. Would you be willing to give just a few sentences, or a few short code snippets of how you would imagine this library being integrated into a reducer-driven TCA app? Just enough to put me on the scent would be great. Many thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
When we use observable models in our demos, they mostly map to TCA reducers:
Otherwise things look mostly the same. So you could take the SyncUps demo, which uses observable models, and consider how it would be ported. But the bottom line is you can use Let us know if you hit any particular stumbling blocks and we'll see if we can help! |
Beta Was this translation helpful? Give feedback.
-
I have a similar question, and I've managed to integrate SharingGRDB with TCA, but I'm struggling to find a way to have dynamic queries work. Specifically, I have defined a @Fetch(Albums(), animation: .default) var albums = Albums.Value() Which I then update as required in the reducer: return .run { _ in
state.$albums.load(Albums())
} The issue I'm having is that I'm not able to call Do you have any guidance on what I could do in this scenario? Thanks! |
Beta Was this translation helpful? Give feedback.
-
I'm struggling a bit with testing SharingGRDB in the Composable Architecture. Normally the But with a shared database this seems not to work. So I have to assert on the state of the database, which means I could miss a change. An alternative would be to treat the database as a dependency and create a But then all the What's the best way to test SharingGRDB? |
Beta Was this translation helpful? Give feedback.
When we use observable models in our demos, they mostly map to TCA reducers:
Otherwise things look mostly the same. So you could take the SyncUps demo, which uses observable models, and consider how it would be ported.
But the bottom line is you can use
@FetchAll
(and@FetchOne
and@Fetch
) wherever you want, or wherever@Shared
properties are held. This includes reducer state, effects, even directly in a view if you want. And you can use@Dependency(\.defaultDatabase)
to write to the database.Let us know if you hit an…