Replies: 1 comment
-
I think it's the case that an action is required to trigger any effects, it's the act of sending an action to the store (or the store receiving an action from an effect) that triggers the reducer evaluation in the first place. How would you expect this to work without an action? If it's an effect that should be triggered when the app launches then you could just send an "app finished launching" action from the app delegate and attach your subscriptions to the root app reducer. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I just stumbled upon an oddity of the Elm-like subscriptions as demonstrated by the sample. As this using an Higher-Order-Reducer, which is only first invoking the subscriptions closure from the reducer body, it only starts observing as soon as there was one action seen in its scope. So essentially, it requires a jump-start to begin observing. This might be a little counter-intuitive or even not quite in the spirit of the composability of TCA.
I ran into this when I had a well isolated reusable subscription, stateless and exclusively publishing a certain action type, so there was never once an other action seen of that type.
I could work around this issue by manually publishing the default value when I expect a subscription.
Details
See how the
subscriptions
closure is only called in theReducer { ... }
body itself. So if there is no initial action, there won't be any subscription.swift-composable-architecture/Examples/CaseStudies/SwiftUICaseStudies/04-HigherOrderReducers-ElmLikeSubscriptions.swift
Lines 13 to 34 in 1ce105f
Beta Was this translation helpful? Give feedback.
All reactions