how to use UserNotificationsDependency delegate #16
Replies: 2 comments 2 replies
-
Hey @corysullivan, sorry to poke into this thread, but I was curious about your comments about the delegate not being set on the main thread, and so possibly losing the cold launch triggers. I looked into it, and it is true that we call await withThrowingTaskGroup(of: Void.self) { group in
group.addTask {
for await event in self.userNotifications.delegate() {
await send(.userNotifications(event))
}
} …however, that endpoint could have been called outside of the effect and then iterated over inside the effect: let notificationEvents = self.userNotifications.delegate()
return .run { send in
await withThrowingTaskGroup(of: Void.self) { group in
group.addTask {
for await event in notificationEvents {
await send(.userNotifications(event))
}
} I think then things would have worked correctly. I just wanted to mention that because it is subtle. It is totally fine to construct the |
Beta Was this translation helpful? Give feedback.
-
Hey @corysullivan! I principally implemented this dependency with Vanilla applications in mind for the time being, so I can't provide a direct example of use in TCA right now. It is maybe possible to make the delegate of this dependency something itself configurable (I mean each endpoint, not just the instance like right now). But delegates are quite common, so I'll think a bit more about a way to generalize the solution. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the great work! This is an excellent addition to the Dependency package and will help clean up my app😀. I did have a question on
UserNotificationsDependency
, specifically how to use the delegate. I have tried using the iso-words implementation found here, this version did not set the delegate on the main thread, and consequently was not set in time for cold launches triggered by a push notification. Therefore, I abandoned this idea. However, it looks like you take a different approach, and I am interested in trying your implementation. Do you have an example illustrating how we should use the delegate in a TCA application? I'm unsure how the delegate events get propagated into a reducer action.Beta Was this translation helpful? Give feedback.
All reactions