File tree Expand file tree Collapse file tree 5 files changed +45
-24
lines changed
Expand file tree Collapse file tree 5 files changed +45
-24
lines changed Original file line number Diff line number Diff line change 1- osx_image : xcode7.1
1+ osx_image : xcode7.3
22language : objective-c
33podfile : Demo/Podfile
44cache : cocoapods
Original file line number Diff line number Diff line change @@ -100,18 +100,18 @@ public extension Action {
100100 let work = self . workFactory ( input)
101101 defer {
102102 // Subscribe to the work.
103- work. multicast ( buffer) . connect ( )
103+ work. multicast ( buffer) . connect ( ) . addDisposableTo ( disposeBag )
104104 }
105105
106- buffer. subscribe ( onNext: { element in
107- self . _elements. onNext ( element)
106+ buffer. subscribe ( onNext: { [ weak self ] element in
107+ self ? . _elements. onNext ( element)
108108 } ,
109- onError: { error in
110- self . _errors. onNext ( ActionError . UnderlyingError ( error) )
109+ onError: { [ weak self ] error in
110+ self ? . _errors. onNext ( ActionError . UnderlyingError ( error) )
111111 } ,
112112 onCompleted: nil ,
113- onDisposed: {
114- self . doLocked { self . _executing. value = false }
113+ onDisposed: { [ weak self ] in
114+ self ? . doLocked { self ? . _executing. value = false }
115115 } )
116116 . addDisposableTo ( disposeBag)
117117
Original file line number Diff line number Diff line change @@ -214,7 +214,7 @@ class ActionTests: QuickSpec {
214214 it ( " only subscribes to observable returned from work factory once " ) {
215215 var invocations = 0
216216 let subject = Action < Void , Void > ( workFactory: { _ in
217- invocations++
217+ invocations += 1
218218 return . empty( )
219219 } )
220220
Original file line number Diff line number Diff line change @@ -106,6 +106,27 @@ class ButtonTests: QuickSpec {
106106
107107 expect ( disposed) == true
108108 }
109+
110+ it ( " cancels the observable if the button is deallocated " ) {
111+
112+ var disposed = false
113+
114+ autoreleasepool {
115+ let subject = UIButton ( type: . System)
116+ let action = CocoaAction {
117+ return Observable . create { _ in
118+ AnonymousDisposable {
119+ disposed = true
120+ }
121+ }
122+ }
123+
124+ subject. rx_action = action
125+ subject. rx_action? . execute ( )
126+ }
127+
128+ expect ( disposed) == true
129+ }
109130 }
110131}
111132
Original file line number Diff line number Diff line change 11PODS:
2- - Action (1.1.0):
3- - RxCocoa (~> 2.1.0)
4- - RxSwift (~> 2.1.0)
5- - Nimble (3.0.0)
6- - Quick (0.8.0)
7- - RxBlocking (2.1.0):
2+ - Action (1.2.1):
3+ - RxCocoa (~> 2.0)
84 - RxSwift (~> 2.0)
9- - RxCocoa (2.1.0):
10- - RxSwift (~> 2.0)
11- - RxSwift (2.1.0)
5+ - Nimble (4.0.1)
6+ - Quick (0.9.2)
7+ - RxBlocking (2.5.0):
8+ - RxSwift (~> 2.5)
9+ - RxCocoa (2.5.0):
10+ - RxSwift (~> 2.5)
11+ - RxSwift (2.5.0)
1212
1313DEPENDENCIES:
1414 - Action (from `../`)
@@ -23,11 +23,11 @@ EXTERNAL SOURCES:
2323 :path: ../
2424
2525SPEC CHECKSUMS:
26- Action: d313d68136ecaa8c8419fcb59d87bd26f2f80522
27- Nimble: 4c353d43735b38b545cbb4cb91504588eb5de926
28- Quick: 563d0f6ec5f72e394645adb377708639b7dd38ab
29- RxBlocking: fa297def258d85c5beae9ed507f94645260b3747
30- RxCocoa: 79b5feb8378545336e756a0a33fcf5e95050b71c
31- RxSwift: 110fb07f81c17c2c3b3254d168363057b1880d18
26+ Action: b602680262545973293b0fd0aca84d1a49141608
27+ Nimble: 0f3c8b8b084cda391209c3c5efbb48bedeeb920a
28+ Quick: 18d057bc66451eedd5d1c8dc99ba2a5db6e60226
29+ RxBlocking: 595d9ab56dde6b00beaa5aba40e95b150d2135f1
30+ RxCocoa: e1b1562e57a554d0fb2aabf9d71b637f177257c7
31+ RxSwift: 402b41a50e922a0368fc14cb3bc9f4427920e8ae
3232
3333COCOAPODS: 0.39.0
You can’t perform that action at this time.
0 commit comments