Beginning RxSwift - Part 8: Subjects and | Ray Wenderlich Videos

Find out how Subjects can receive new elements and emit new events to subscribers at runtime.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4743-beginning-rxswift/lessons/8

I think Variable is deprecated. I heard from on Slack group that I should prefer something like: BehaviorRelay

1 Like

Hello. There is an error in the downloaded files…
47%20PM

print(label, (event.element ?? event.error) ?? event)

why after using the disposed(by: disposableBag) instead of dispose()

on subscriptionOne.dispose()

it didn’t disposed?

@scotteg Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi @scel, I am not sure about your question, but to distinguish between calling dispose() on a subscription vs. adding it to a DisposeBag instance, calling dispose() is immediate, and adding it to a DisposeBag instance means that when deinit is called on that instance, i.e., when it is about to be deallocated, it calls dispose() on each item previously added to it. Here’s the relevant portion of the DisposeBag implementation:

    /// This is internal on purpose, take a look at `CompositeDisposable` instead.
    private func dispose() {
        let oldDisposables = _dispose()

        for disposable in oldDisposables {
            disposable.dispose()
        }
    }

    private func _dispose() -> [Disposable] {
        _lock.lock(); defer { _lock.unlock() }

        let disposables = _disposables
        
        _disposables.removeAll(keepingCapacity: false)
        _isDisposed = true
        
        return disposables
    }
    
    deinit {
        dispose()
    }

Somehow the supporting files are not getting downloaded when I download the materials for any episode so far in part 1.

@shreya I could download everything without any issues - do you still have problems with this?

Thank you.
This help me with the console output of
Optional(nil)