Let's say I have a UIButton
in a UITableViewCell
.
After dequeuing the cell from the UITableView
I want to subscribe to the UIButton.rx.tap
. The issue is that if my UITableViewCell
is dequeued multiple times, the subscriptions would retain. Currently I solve this problem by allocating a Disposable
property in my UITableViewCell
, setting it when the subscription is create, and calling Disposable.dispose()
on UITableViewCell.prepareForReuse()
, however as far as I understand implementing features in a way that requires you to call Disposable.dispose()
implies that you are doing something wrong.
Is there any better way to accomplish uniqueness of the subscription without reallocating UIButton
?