Currently I'm still using Swift 2x. My code:
NSNotificationCenter.defaultCenter().rx_notification(string)
NSNotificationCenter.defaultCenter().rx_notification(string, object: self) -> no effect
I need to know how to remove obsever in case 1:
NSNotificationCenter.defaultCenter().removeObserver(self, forKeyPath: string) -> runtime error
NSNotificationCenter.defaultCenter().rx_notification("blabla").dispose()
this observer will be removed on dispose.
This seems out of date, it looks like you would have to do this with a disposeBag now
@Stoff81 I'm not sure what drove you to comment on an issue ~over~ almost 2 years old :)
Just thought it might be helpful for the next person that comes here.
You could still dispose the subscription manually, as the original comment suggested. Nothing has changed in that regard. A DisposeBag is just used to tie the memory of subscriptions to some owner so they're disposed together.
NotificationCenter.default.rx.notification(.UIKeyboardWillHide).dispose() does not compile actually
You can only Dispose a subscription - so you would need to actually need to subscribe to it to dispose it.
Please start a new Issue if you have additional questions. It's not a great practice to bump such an old thread, as the content is not 100% up to date, as you mentioned.
Thanks for the understanding :)
This is exactly what I said in my initial comment!
Again and hopefully I can make this clear :)
A DisposeBag and Disposable are two different things. You need to subscribe, in both ways.
let subscription = somethingThatMakesAStream.subscribe() // Disposable
// Adds to a DisposeBag so it will be disposed with deallocation
subscription.disposed(by: disposeBag)
// But, you can still dispose manually, like mentioned in the original comment
subscription.dispose()
Most helpful comment
Again and hopefully I can make this clear :)
A
DisposeBagandDisposableare two different things. You need to subscribe, in both ways.