Skip to content

Instantly share code, notes, and snippets.

@hajipy
Created September 11, 2016 13:02
Show Gist options
  • Save hajipy/303c77cd593f6eaf1772700c1583d514 to your computer and use it in GitHub Desktop.
Save hajipy/303c77cd593f6eaf1772700c1583d514 to your computer and use it in GitHub Desktop.
ドメインイベントをObservableに変換
import Foundation
import RxSwift
import SwiftEventBus
class Query {
static func query() -> Observable<String> {
return Observable.create { observer in
SwiftEventBus.onMainThread(self, name: "SomeDomainEvent") { result in
observer.on(.Next("SomeDomainEvent"))
}
return AnonymousDisposable {
SwiftEventBus.unregister("SomeDomainEvent")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment