fix rxswift memory leak

FFIB 6 年之前
父节点
当前提交
5a07bc1a79

+ 1 - 0
PaiAi/Cartfile

@@ -1,4 +1,5 @@
1 1
 github "Yalantis/PullToRefresh"
2
+github "eggswift/pull-to-refresh"
2 3
 github "ReactiveX/RxSwift" ~> 5.0
3 4
 github "onevcat/Kingfisher" ~> 5.0
4 5
 github "Alamofire/Alamofire" "5.0.0-beta.1"

+ 1 - 0
PaiAi/Cartfile.resolved

@@ -2,5 +2,6 @@ github "Alamofire/Alamofire" "5.0.0-beta.1"
2 2
 github "ReactiveX/RxSwift" "5.0.1"
3 3
 github "RxSwiftCommunity/RxDataSources" "4.0.1"
4 4
 github "Yalantis/PullToRefresh" "3.1"
5
+github "eggswift/pull-to-refresh" "2.9"
5 6
 github "onevcat/Kingfisher" "5.5.0"
6 7
 github "tristanhimmelman/ObjectMapper" "3.4.2"

+ 2 - 0
PaiAi/Paiai.xcodeproj/project.pbxproj

@@ -1557,6 +1557,7 @@
1557 1557
 				"$(SRCROOT)/Carthage/Build/iOS/PullToRefresh.framework",
1558 1558
 				"$(SRCROOT)/Carthage/Build/iOS/Differentiator.framework",
1559 1559
 				"$(SRCROOT)/Carthage/Build/iOS/RxRelay.framework",
1560
+				"$(SRCROOT)/Carthage/Build/iOS/ESPullToRefresh.framework",
1560 1561
 			);
1561 1562
 			name = "Run Script";
1562 1563
 			outputPaths = (
@@ -1569,6 +1570,7 @@
1569 1570
 				"$(DERIVED_FILE_DIR)/$(FRAMEWORKS_FOLDER_PATH)/RxCocoa.framework",
1570 1571
 				"$(DERIVED_FILE_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Differentiator.framework",
1571 1572
 				"$(DERIVED_FILE_DIR)/$(FRAMEWORKS_FOLDER_PATH)/RxRelay.framework",
1573
+				"$(DERIVED_FILE_DIR)/$(FRAMEWORKS_FOLDER_PATH)/ESPullToRefresh.framework",
1572 1574
 			);
1573 1575
 			runOnlyForDeploymentPostprocessing = 0;
1574 1576
 			shellPath = /bin/sh;

二进制
PaiAi/Paiai.xcodeproj/project.xcworkspace/xcuserdata/FFIB.xcuserdatad/UserInterfaceState.xcuserstate


+ 1 - 0
PaiAi/Paiai/AppDelegate.swift

@@ -34,6 +34,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {
34 34
             registerAppConfiguration()
35 35
 
36 36
             window = UIWindow(frame: UIScreen.main.bounds)
37
+            window?.backgroundColor = .white
37 38
             coordinator = AppCoordinator(window: window!)
38 39
 
39 40
             coordinator?.start().subscribe().disposed(by: disposeBag)

+ 4 - 2
PaiAi/PaiaiDataKit/PresentLayer/Group/GroupViewModel.swift

@@ -107,7 +107,8 @@ public class GroupViewModel {
107 107
     }
108 108
 
109 109
     private func setNotification() {
110
-        NotificationCenter.default.rx.notification(.GroupItemsChanged).subscribe(onNext: { (notification) in
110
+        NotificationCenter.default.rx.notification(.GroupItemsChanged).subscribe(onNext: {
111
+            (notification) in
111 112
             guard let itemOperator = notification.userInfo?[GroupItemsOperator.key] as? GroupItemsOperator,
112 113
                 case let .update(_, val) = itemOperator else { return }
113 114
             self.groupItem.accept(val)
@@ -123,7 +124,8 @@ public class GroupViewModel {
123 124
 
124 125
         }).disposed(by: disposeBag)
125 126
 
126
-        NotificationCenter.default.rx.notification(.PhotoItemsChanged).subscribe(onNext: { (notification) in
127
+        NotificationCenter.default.rx.notification(.PhotoItemsChanged).subscribe(onNext: {
128
+            (notification) in
127 129
             guard let itemOperator = notification.userInfo?[PhotoItemsOperator.key] as? PhotoItemsOperator,
128 130
                 case let .update(id, val) = itemOperator,
129 131
                 let index = self._items.value.firstIndex(where: { $0.photo_id == id }) else { return }

+ 14 - 11
PaiAi/PaiaiDataKit/PresentLayer/Home/HomeViewModel.swift

@@ -20,7 +20,7 @@ public protocol HomeViewModelDelegate: class {
20 20
 public class HomeViewModel {
21 21
 
22 22
     private var page: Int = 1
23
-    private let disposeBag = DisposeBag()
23
+    
24 24
 
25 25
     private var repository: HomeRepository
26 26
 
@@ -44,19 +44,18 @@ public class HomeViewModel {
44 44
             return [AnimatableSectionModel(model: "photoItem", items: model)]
45 45
         })
46 46
     }
47
-
47
+    
48
+    private let disposeBag = DisposeBag()
48 49
     public weak var delegate: HomeViewModelDelegate?
49 50
 
50 51
     public init() {
51 52
         self.repository = HomeRepository()
52 53
 
53
-        scanBtnTapped.subscribe({ [weak self] _ in
54
-            guard let `self` = self else { return }
54
+        scanBtnTapped.subscribe({ [unowned self] _ in
55 55
             self.delegate?.scanQR()
56 56
         }).disposed(by: disposeBag)
57 57
 
58
-        createBtnTapped.subscribe({ [weak self] _ in
59
-            guard let `self` = self else { return }
58
+        createBtnTapped.subscribe({ [unowned self] _ in
60 59
             self.delegate?.createGroup()
61 60
         }).disposed(by: disposeBag)
62 61
 
@@ -107,9 +106,11 @@ public class HomeViewModel {
107 106
     }
108 107
 
109 108
     private func setNotification() {
110
-        NotificationCenter.default.rx.notification(.GroupItemsChanged).subscribe(onNext: { (notification) in
109
+        NotificationCenter.default.rx.notification(.GroupItemsChanged).subscribe(onNext: {
110
+            [unowned self] (notification) in
111 111
             guard let userInfo = notification.userInfo,
112
-            let itemOperator = userInfo[GroupItemsOperator.key] as? GroupItemsOperator else { return }
112
+                let itemOperator = userInfo["operator"] as? GroupItemsOperator else { return }
113
+
113 114
             var items = self._items.value
114 115
             switch itemOperator {
115 116
             case let .update(groupId, val):
@@ -130,10 +131,12 @@ public class HomeViewModel {
130 131
             }
131 132
         }).disposed(by: disposeBag)
132 133
 
133
-        NotificationCenter.default.rx.notification(.PhotoItemsChanged).subscribe(onNext: { (notification) in
134
-            guard let itemOperator = notification.userInfo?[PhotoItemsOperator.key] as? PhotoItemsOperator,
134
+        NotificationCenter.default.rx.notification(.PhotoItemsChanged).subscribe(onNext: {
135
+            [unowned self] (notification) in
136
+            guard let itemOperator = notification.userInfo?["operator"] as? PhotoItemsOperator,
135 137
                 case let .update(photoId, val) = itemOperator,
136
-                let index = self._items.value.firstIndex(where: { $0.photo_id == photoId }) else { return }
138
+                let index = self._items.value.firstIndex(where: { $0.photo_id == photoId })
139
+                else { return }
137 140
             var items = self._items.value
138 141
             items[index] = val
139 142
             self._items.accept(items)

+ 3 - 6
PaiAi/PaiaiDataKit/PresentLayer/Message/MessageViewModel.swift

@@ -34,20 +34,17 @@ public class MessageViewModel {
34 34
     public init() {
35 35
         self.repository = MessageRepository()
36 36
 
37
-        sysBtnTapped.asObservable().subscribe {[weak self] (_) in
38
-            guard let `self` = self else { return }
37
+        sysBtnTapped.asObservable().subscribe {[unowned self] _ in
39 38
             self.readedTip = self.sysReadedTip
40 39
             self.delegate?.didSelect(type: .system)
41 40
         }.disposed(by: disposeBag)
42 41
 
43
-        commentBtnTapped.asObservable().subscribe {[weak self] (_) in
44
-            guard let `self` = self else { return }
42
+        commentBtnTapped.asObservable().subscribe {[unowned self] _ in
45 43
             self.readedTip = self.commentReadedTip
46 44
             self.delegate?.didSelect(type: .comment)
47 45
         }.disposed(by: disposeBag)
48 46
 
49
-        thumbupBtnTapped.asObservable().subscribe {[weak self] (_) in
50
-            guard let `self` = self else { return }
47
+        thumbupBtnTapped.asObservable().subscribe {[unowned self] _ in
51 48
             self.readedTip = self.thumbupReadedTip
52 49
             self.delegate?.didSelect(type: .thumbup)
53 50
         }.disposed(by: disposeBag)

+ 0 - 1
PaiAi/PaiaiDataKit/PresentLayer/PhotoDetail/PhotoDetailItemViewModel.swift

@@ -47,7 +47,6 @@ public final class PhotoDetailItemViewModel {
47 47
     }
48 48
     
49 49
     private func loadThumbupAndComment() {
50
-        print(#function)
51 50
         Single.zip(repository.loadComments(), repository.loadThumbups()).subscribe(onSuccess: {[unowned self] (commentItems, thumbupItems) in
52 51
             self.commentItems.accept(commentItems)
53 52
             self.thumbupItems.accept(thumbupItems)

+ 0 - 1
PaiAi/PaiaiDataKit/PresentLayer/PhotoDetail/PhotoDetailViewModel.swift

@@ -127,7 +127,6 @@ public final class PhotoDetailViewModel {
127 127
     }
128 128
 
129 129
     public func willShow(index: Int) {
130
-        print(index)
131 130
         currIndex = index
132 131
         _hasGetPrice.accept(false)
133 132
         itemViewModel.item.accept(_items.value[index])

+ 15 - 12
PaiAi/PaiaiUIKit/Reusable/UIKit/NavigationController/NavigationController.swift

@@ -11,10 +11,10 @@ import UIKit
11 11
 public class NavigationController: UINavigationController {
12 12
     
13 13
     private var operation: Operation = .none
14
-    private var barConfigures: [UIViewController?: NavigationBarConfiguration] = [:]
14
+    private var barConfigures = [UIViewController: NavigationBarConfiguration]()
15 15
     
16
-    private var _fromFakeBar = UIToolbar()
17
-    private var _toFakeBar = UIToolbar()
16
+    private var _fromFakeBar: UIToolbar? = nil
17
+    private var _toFakeBar: UIToolbar? = nil
18 18
     
19 19
     override public init(rootViewController: UIViewController) {
20 20
         super.init(navigationBarClass: NavigationBar.classForCoder(), toolbarClass: nil)
@@ -73,24 +73,27 @@ fileprivate extension NavigationController {
73 73
     func setFromFakeNavigationBar(for from: UIViewController) {
74 74
         if let navBarFrame = from.getFakeBarFrame(for: navigationBar) {
75 75
             _fromFakeBar = UIToolbar(configure: barConfigures[from] ?? .default)
76
-            _fromFakeBar.delegate = self
77
-            _fromFakeBar.frame = navBarFrame
78
-            from.view.addSubview(_fromFakeBar)
76
+            _fromFakeBar?.delegate = self
77
+            _fromFakeBar?.frame = navBarFrame
78
+            from.view.addSubview(_fromFakeBar!)
79 79
         }
80 80
     }
81 81
     
82 82
     func setToFakeNavigationBar(for to: UIViewController) {
83 83
         if let navBarFrame = to.getFakeBarFrame(for: navigationBar) {
84 84
             _toFakeBar = UIToolbar(configure: barConfigures[to] ?? .default)
85
-            _toFakeBar.delegate = self
86
-            _toFakeBar.frame = navBarFrame
87
-            to.view.addSubview(_toFakeBar)
85
+            _toFakeBar?.delegate = self
86
+            _toFakeBar?.frame = navBarFrame
87
+            to.view.addSubview(_toFakeBar!)
88 88
         }
89 89
     }
90 90
     
91 91
     func clearFake() {
92
-        _fromFakeBar.removeFromSuperview()
93
-        _toFakeBar.removeFromSuperview()
92
+        _fromFakeBar?.removeFromSuperview()
93
+        _toFakeBar?.removeFromSuperview()
94
+        
95
+        _fromFakeBar = nil
96
+        _toFakeBar = nil
94 97
         
95 98
         guard let from = transitionCoordinator?.viewController(forKey: .from),
96 99
             operation == .pop else { return }
@@ -130,7 +133,7 @@ extension NavigationController: UINavigationControllerDelegate {
130 133
                 vc = context.viewController(forKey: .to)
131 134
             }
132 135
             self.navigationBar.getBarBackground()?.alpha = 1
133
-            self.navigationBar.apply(for: self.barConfigures[vc] ?? .default)
136
+            self.navigationBar.apply(for: self.barConfigures[vc!] ?? .default)
134 137
             self.clearFake()
135 138
         })
136 139
     }

+ 0 - 1
PaiAi/Paiai_iOS/App/AppCoordinator.swift

@@ -23,7 +23,6 @@ public final class AppCoordinator: BaseCoordinator<Void> {
23 23
     public init(window: UIWindow) {
24 24
         self.window = window
25 25
         self.containerViewController = ContainerViewController()
26
-
27 26
         super.init(navigationController: NavigationController(rootViewController: containerViewController),
28 27
                    viewController: containerViewController)
29 28
     }

+ 5 - 0
PaiAi/Paiai_iOS/App/Group/GroupViewController.swift

@@ -82,6 +82,11 @@ final class GroupViewController: UIViewController {
82 82
         collectionView.startRefreshing(at: .top)
83 83
     }
84 84
 
85
+    override func removeFromParent() {
86
+        super.removeFromParent()
87
+        print(self)
88
+    }
89
+    
85 90
     deinit {
86 91
         collectionView.removeAllPullToRefresh()
87 92
     }

+ 1 - 1
PaiAi/Paiai_iOS/App/Home/HomeCoordinator.swift

@@ -29,7 +29,7 @@ class HomeCoordinator: BaseCoordinator<Void> {
29 29
     @discardableResult
30 30
     override func start() -> Observable<Void> {
31 31
         homeViewController.viewModel.delegate = self
32
-
32
+        deallocatedDispose.dispose()
33 33
         return Observable.never()
34 34
     }
35 35
 }

+ 17 - 25
PaiAi/Paiai_iOS/App/Home/HomeViewController.swift

@@ -10,7 +10,7 @@ import RxCocoa
10 10
 import RxDataSources
11 11
 import PaiaiDataKit
12 12
 import PaiaiUIKit
13
-import PullToRefresh
13
+import ESPullToRefresh
14 14
 
15 15
 final class HomeViewController: UIViewController {
16 16
 
@@ -20,22 +20,14 @@ final class HomeViewController: UIViewController {
20 20
     // MARK: data property
21 21
     fileprivate let disposeBag = DisposeBag()
22 22
 
23
-    internal var viewModel: HomeViewModel!
24
-    internal var userInfoViewModel: UserInfoViewModel!
23
+    var viewModel: HomeViewModel!
24
+    var userInfoViewModel: UserInfoViewModel!
25 25
 
26 26
     override func viewDidLoad() {
27 27
         super.viewDidLoad()
28 28
         initalize()
29 29
     }
30 30
 
31
-    override func viewDidAppear(_ animated: Bool) {
32
-        super.viewDidAppear(animated)
33
-    }
34
-    
35
-    override func viewDidDisappear(_ animated: Bool) {
36
-        super.viewDidDisappear(animated)
37
-    }
38
-
39 31
     func initalize() {
40 32
         collectionView.register(UINib(nibName: "PhotoCell",
41 33
                                       bundle: Bundle(identifier: "com.Paiai-iOS")),
@@ -51,22 +43,22 @@ final class HomeViewController: UIViewController {
51 43
     }
52 44
 
53 45
     private func setupReloadControl() {
54
-        collectionView.addPullToRefresh(PullToRefresh()) {
46
+        collectionView.es.addPullToRefresh {
55 47
             [unowned self] in
56 48
             self.viewModel.reload()
57 49
         }
58 50
     }
59 51
 
60 52
     private func setupLoadingControl() {
61
-        collectionView.addPullToRefresh(PullToRefresh(position: .bottom)) {
62
-            [weak self] in
63
-            guard let `self` = self else { return }
53
+        collectionView.es.addInfiniteScrolling {
54
+            [unowned self] in
64 55
             self.viewModel.preload()
65 56
         }
66 57
     }
67 58
 
68 59
     deinit {
69
-        collectionView.removeAllPullToRefresh()
60
+        collectionView.es.removeRefreshFooter()
61
+        collectionView.es.removeRefreshHeader()
70 62
     }
71 63
 }
72 64
 
@@ -100,11 +92,12 @@ fileprivate extension HomeViewController {
100 92
     func bindViewModelToRefreshing() {
101 93
         viewModel.isLoading
102 94
             .asDriver(onErrorJustReturn: true)
103
-            .drive(onNext: {[unowned self] flag in
95
+            .drive(onNext: {[weak self] flag in
96
+                guard let `self` = self else { return }
104 97
                 if flag {
105
-                    self.collectionView.endRefreshing(at: .top)
98
+                    self.collectionView.es.stopPullToRefresh()
106 99
                 } else {
107
-                    self.collectionView.endRefreshing(at: .bottom)
100
+                    self.collectionView.es.stopLoadingMore()
108 101
                 }
109 102
             }).disposed(by: disposeBag)
110 103
     }
@@ -114,12 +107,11 @@ fileprivate extension HomeViewController {
114 107
     }
115 108
 
116 109
     func bindUserInfoViewModelToView() {
117
-        userInfoViewModel.isLoggedIn
118
-            .asDriver(onErrorJustReturn: ())
119
-            .drive(onNext: {[unowned self] _ in
120
-                self.viewModel.clear()
121
-                self.collectionView.startRefreshing(at: .top)
122
-            }).disposed(by: disposeBag)
110
+        userInfoViewModel.isLoggedIn.subscribe({[weak self] _ in
111
+            guard let `self` = self else { return }
112
+            self.viewModel.clear()
113
+            self.collectionView.startRefreshing(at: .top)
114
+        }).disposed(by: disposeBag)
123 115
     }
124 116
 
125 117
     func bindViewModelToCollectionView() {

+ 1 - 0
PaiAi/Paiai_iOS/App/Message/MessageCoordinator.swift

@@ -22,6 +22,7 @@ class MessageCoordinator: BaseCoordinator<Void> {
22 22
 
23 23
     override func start() -> Observable<Void> {
24 24
         messageViewController.viewModel.delegate = self
25
+        deallocatedDispose.dispose()
25 26
         return Observable.never()
26 27
     }
27 28
 }

+ 14 - 4
PaiAi/Paiai_iOS/App/Mine/MineAboutViewController.swift

@@ -7,8 +7,8 @@
7 7
 //
8 8
 
9 9
 import UIKit
10
-import PaiaiDataKit
11 10
 import PaiaiUIKit
11
+
12 12
 import RxSwift
13 13
 
14 14
 final class MineAboutViewController: UIViewController {
@@ -30,6 +30,15 @@ final class MineAboutViewController: UIViewController {
30 30
         versionLabel.text = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
31 31
         bindGestures()
32 32
     }
33
+    
34
+    override func viewDidDisappear(_ animated: Bool) {
35
+        super.viewDidDisappear(animated)
36
+        
37
+    }
38
+    
39
+    deinit {
40
+        print("deinit")
41
+    }
33 42
 }
34 43
 
35 44
 fileprivate extension MineAboutViewController {
@@ -42,7 +51,7 @@ fileprivate extension MineAboutViewController {
42 51
     func bindGestureToContactUsAction() {
43 52
         contactUsBtn.rx.tap
44 53
             .asObservable()
45
-            .subscribe { (_) in
54
+            .subscribe { [unowned self] _ in
46 55
                 let webVC = WebViewController(title: "联系我们",
47 56
                                               path: "https://pai.ai/page/contact_us")
48 57
                 self.navigationController?.pushViewController(webVC)
@@ -52,7 +61,7 @@ fileprivate extension MineAboutViewController {
52 61
     func bindGestureToScoreAction() {
53 62
         scoreBtn.rx.tap
54 63
             .asObservable()
55
-            .subscribe { (_) in
64
+            .subscribe {  _ in
56 65
                 guard let url = URL(string: "https://itunes.apple.com/cn/app/pai-aipaiai/id1163960351?mt=8") else {
57 66
                     return
58 67
                 }
@@ -63,7 +72,7 @@ fileprivate extension MineAboutViewController {
63 72
     func bindGestureToUserAgreementAction() {
64 73
         userAgreementBtn.rx.tap
65 74
             .asObservable()
66
-            .subscribe { (_) in
75
+            .subscribe { [unowned self] _ in
67 76
                 let webVC = WebViewController(title: "用户协议",
68 77
                                               path: "https://pai.ai/page/user_agreement")
69 78
                 self.navigationController?.pushViewController(webVC)
@@ -78,3 +87,4 @@ extension MineAboutViewController: Storyboarded {
78 87
         return UIStoryboard.mine.instantiateViewController(type: MineAboutViewController.self)
79 88
     }
80 89
 }
90
+

+ 5 - 7
PaiAi/Paiai_iOS/App/Mine/MineCoordinator.swift

@@ -25,8 +25,6 @@ class MineCoordinator: BaseCoordinator<Void> {
25 25
         mineViewController.delegate = self
26 26
         return didCancel
27 27
     }
28
-
29
-    override func listenDeallocate() {}
30 28
 }
31 29
 
32 30
 extension MineCoordinator: MineViewControllerDelegate {
@@ -46,7 +44,7 @@ extension MineCoordinator: MineViewControllerDelegate {
46 44
 
47 45
     func didSelect(_ item: MineItem) {
48 46
         mineViewController.dismissController()
49
-
47
+        deallocatedDispose.dispose()
50 48
         let vc: UIViewController
51 49
         switch item {
52 50
         case .group:
@@ -58,8 +56,8 @@ extension MineCoordinator: MineViewControllerDelegate {
58 56
         case .about:
59 57
             vc = makeMineAboutViewController()
60 58
         }
61
-
62
-        vc.rx.deallocated.subscribe(onNext: { _ in
59
+        
60
+        vc.rx.deallocating.subscribe(onNext: { _ in
63 61
             self.didCancel.onNext(())
64 62
         }).disposed(by: disposeBag)
65 63
     }
@@ -103,8 +101,8 @@ fileprivate extension MineCoordinator {
103 101
 
104 102
     func makeMineAboutViewController() -> MineAboutViewController {
105 103
         let vc = MineAboutViewController.instantiate()
106
-        navigationController.pushViewController(vc)
107
-
104
+        navigationController.pushViewController(vc, animated: true)
105
+        print(navigationController)
108 106
         return vc
109 107
     }
110 108
 

+ 10 - 11
PaiAi/Paiai_iOS/Reusable/BaseCoordinator.swift

@@ -7,7 +7,7 @@
7 7
 //
8 8
 
9 9
 import RxSwift
10
-import Foundation
10
+import UIKit
11 11
 
12 12
 public class BaseCoordinator<ResultType> {
13 13
 
@@ -15,6 +15,7 @@ public class BaseCoordinator<ResultType> {
15 15
 
16 16
     let disposeBag = DisposeBag()
17 17
     var didCancel = PublishSubject<Void>()
18
+    var deallocatedDispose = Disposables.create()
18 19
     var navigationController: UINavigationController
19 20
     var viewController: UIViewController
20 21
 
@@ -25,7 +26,13 @@ public class BaseCoordinator<ResultType> {
25 26
     init(navigationController: UINavigationController, viewController: UIViewController) {
26 27
         self.viewController = viewController
27 28
         self.navigationController = navigationController
28
-        listenDeallocate()
29
+        
30
+        deallocatedDispose = viewController.rx.viewDidDisappear.subscribe(onNext: {[weak self] _ in
31
+            guard let `self` = self else { return }
32
+            if !self.navigationController.viewControllers.contains(viewController) {
33
+                self.didCancel.onNext(())
34
+            }
35
+        })
29 36
     }
30 37
 
31 38
     private func store<T>(coordinator: BaseCoordinator<T>) {
@@ -33,6 +40,7 @@ public class BaseCoordinator<ResultType> {
33 40
     }
34 41
 
35 42
     private func free<T>(coordinator: BaseCoordinator<T>) {
43
+        print(coordinator)
36 44
         childCoordinators[coordinator.identifier] = nil
37 45
     }
38 46
 
@@ -48,13 +56,4 @@ public class BaseCoordinator<ResultType> {
48 56
     func start() -> Observable<ResultType> {
49 57
         fatalError("Start method should be implemented.")
50 58
     }
51
-
52
-    func listenDeallocate() {
53
-        navigationController.rx.willShow.subscribe(onNext: {[weak self] (_, _) in
54
-            guard let `self` = self else { return }
55
-            if !self.navigationController.viewControllers.contains(self.viewController) {
56
-                self.didCancel.onNext(())
57
-            }
58
-        }).disposed(by: disposeBag)
59
-    }
60 59
 }