Skip to content

What is the best practice to set up a long-live publisher into a reducer without duplication? #1549

Answered by tgrapperon
ylorn asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @ylorn, thanks for the very nice case presentation. There is one thing that are not quite right in your implementation. In .viewAppear, you create a subscription to the apiClient, but you're not holding any reference to it. If this view disappears, the subscription will still be active and will start to emit actions for this non-existing Demo domain. This is considered as a programming error in TCA. Furthermore, if it appears again, it will indeed create a new subscription. There are two ways to fix this issue:

  • You need an identifier to tag this subscription. The most convenient way is to introduce an empty enum and use this type as an identifier itself. You can sometimes use the red…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by ylorn
Comment options

You must be logged in to vote
5 replies
@tgrapperon
Comment options

@tgrapperon
Comment options

@ylorn
Comment options

@tgrapperon
Comment options

@ylorn
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants