There is retain cycle between the Signal
(a Signal
is created when you start the producer, hence the name: SignalProducer
) and the observer, when you use methods of the family start...
.
You have three ways to break this cycle:
- You dispose of the
SignalProducer
(if you notice, you get aDisposable
, when you use astart...
). You should avoid doing this, as it goes against RAC best practises - You have a way to manipulate the
SignalProducer
. In your case you do have, by sending complete to theObserver
. - You use methods like
take
,takeWhile
,until
, which will terminate theSignalProducer
. This is the prefered way.
Regarding the dispatch. Try this in your viewDidLoad
: