RxSwiftCommunity / RxRealm

RxSwift extension for RealmSwift's types
MIT License
1.15k stars 265 forks source link

Delay on Observable.from? #58

Closed tomwilsn closed 7 years ago

tomwilsn commented 7 years ago

Is it just me or is there a big delay when using observables from realm objects?

Using them to try to bind to labels etc leaves me with a flash of the original storyboard value whenever a view appears - or worse if you use a UIPageController, the scrolling stops the main run loop from executing so the labels won't update until you finish scrolling to the new page.

Is there any way around this?

icanzilb commented 7 years ago

Realm notifications are delivered on the runloop of the thread where you create the subscription.

That being said, UIKit assigns highest priority to scrolling on the main thread and Realm just doesn't manage to deliver its own notifications until UIKit is blocking the main thread.

That being said, considering the situations you describe - it might be a viable option to change how RxRealm works a bit to address these situations. We can change for the first emitted element to be delivered synchronously upon subscription and this will probably solve the UI issues you describe.

Can you be more precise about what "big delay" means in your case - is it a second or two, or some minutes?

icanzilb commented 7 years ago

addressed in https://github.com/RxSwiftCommunity/RxRealm/pull/61 with a new parameter that sets whether to emit the first element sync or async 👍🏼