Group Group Group Group Group Group Group Group Group

Please explain when to use asObservable() in Chapter 4, page 90

#1

In Chapter 4, page 90, these lines of code:

images.asObservable()
.subscribe(onNext: { [weak self] photos in
self?.updateUI(photos: photos)
})
.disposed(by: bag)

as Observable() is not explained. On Page 89, asObservable() is not called with this code:

images
.subscribe(onNext: { [weak imagePreview] photos in
guard let preview = imagePreview else { return }
preview.image = photos.collage(size: preview.frame.size)
})
.disposed(by: bag)

Please explain when to use .asObservable() and when to subscribe use the Relay itself.

Thanks,
Mike

1 Like
#2

Hey guys! I’ve just came with the same question… The example on page 90 has the asObservable call, but looks like the behaviour is the same as without this call. Could you specify please why exactly should we use or not this call? (asObservable)
Thanks!