title: MVVM-C with RxSwift: '[weak self]' in closure
body: <p>I'm working on an iOS project with RxSwift and I use the MVVM with coordinators pattern.</p>
  
  <p>Here my implementation:</p>
  
  <p><em>ViewModel:</em></p>
  
  <pre><code>// MARK: - Private
  
  private let showNextViewSubject = PublishSubject&lt;Void&gt;()
  
  // MARK: - Inputs
  
  var showNextView: AnyObserver&lt;Void&gt; {
      return showNextViewSubject.asObserver()
  }
  
  // MARK: - Outputs
  
  var didShowNextView: Observable&lt;Void&gt; {
      return showNextViewSubject.asObservable()
  }
  </code></pre>
  
  <p><em>ViewController:</em></p>
  
  <pre><code>private func bindButton() {
      _ = button.rx.tap
          .bind(to: viewModel.showNextView)
          .disposed(by: disposeBag)
  }
  </code></pre>
  
  <p><em>Coordinator:</em></p>
  
  <pre><code>self.viewModel.didShowNextView
          .subscribe(onNext: { [weak self] _ in
              self?.showNextView()
          })
          .disposed(by: disposeBag)
  </code></pre>
  
  <p>My problem is with the <code>[weak self] _</code> in the coordinator: when I add it, <code>self?.showNextView()</code> is never called, but this works well when I remove it.</p>
  
  <p>Do you know why?</p>
  
  <p>Thanks,
  Romain</p>