To make a Core Data model observable in Swift using RxSwift, we can use the RxCoreData
library. Here are the steps:
Add pod 'RxCoreData'
to your Podfile and run pod install
in Terminal
Import RxCoreData
and RxSwift
main.swift33 chars3 lines
Observable<[NSManagedObject]>
using asObservable()
methodmain.swift153 chars5 lines
main.swift118 chars4 lines
We can also filter/sort the entities based on our requirements by modifying the fetch request before converting it to an Observable.
gistlibby LogSnag