Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Sources/DataSources/RxHelper/ASDelegateProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ extension ObservableType {
where DelegateProxy.ParentObject: ASDisplayNode {

let proxy = DelegateProxy.proxy(for: object)
let unregisterDelegate = DelegateProxy.installForwardDelegate(dataSource, retainDelegate: retainDataSource, onProxyForObject: object)

// ensure dispose unregisterDelegate on main thread
let unregisterDelegate = ScheduledDisposable(
scheduler: MainScheduler.instance,
disposable: DelegateProxy.installForwardDelegate(dataSource, retainDelegate: retainDataSource, onProxyForObject: object)
)

// this is needed to flush any delayed old state (https://github.com/RxSwiftCommunity/RxDataSources/pull/75)
object.layoutIfNeeded()

Expand Down Expand Up @@ -49,7 +55,7 @@ extension ObservableType {
default:
break
}
}
}

return Disposables.create { [weak object] in
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about usingScheduledDisposable ?

let disposable = Disposable.create { /* do something */ }
ScheduledDisposable(scheduler: MainScheduler(), disposable: disposable)

subscription.dispose()
Expand Down