mirror of
https://github.com/modo-studio/SugarRecord.git
synced 2024-09-11 14:36:41 +03:00
Rename Observable to RequestObservable. All tests passing.
Signed-off-by: John Grange <john.grange.ny@gmail.com>
This commit is contained in:
parent
f7a8ae1ae8
commit
e1eb2796a8
@ -327,7 +327,7 @@
|
||||
230CBDC51BF383D700C43A48 /* RealmDefaultStorageTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmDefaultStorageTests.swift; sourceTree = "<group>"; };
|
||||
231015241CDC8EC3004486FA /* Observable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Observable.swift; sourceTree = "<group>"; };
|
||||
2310152E1CDC8EE7004486FA /* RealmObservable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmObservable.swift; sourceTree = "<group>"; };
|
||||
231015371CDC9C64004486FA /* Observable+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Observable+Rx.swift"; sourceTree = "<group>"; };
|
||||
231015371CDC9C64004486FA /* Observable+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "Observable+Rx.swift"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
|
||||
231015401CDC9F0B004486FA /* Observable+ReactiveCocoa.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Observable+ReactiveCocoa.swift"; sourceTree = "<group>"; };
|
||||
2310154A1CDCB529004486FA /* RealmObservableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmObservableTests.swift; sourceTree = "<group>"; };
|
||||
2310154C1CDCCA42004486FA /* CoreDataObservable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreDataObservable.swift; sourceTree = "<group>"; };
|
||||
@ -339,7 +339,7 @@
|
||||
231C61EE1C17482100CD6532 /* CoreData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreData.swift; sourceTree = "<group>"; };
|
||||
231C61F01C174BE000CD6532 /* NSManagedObjectMemoryContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSManagedObjectMemoryContext.swift; sourceTree = "<group>"; };
|
||||
2333900F1C67B41400844B9D /* ReactiveStorage+ReactiveCocoa.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ReactiveStorage+ReactiveCocoa.swift"; sourceTree = "<group>"; };
|
||||
233390111C67B41400844B9D /* ReactiveStorage+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ReactiveStorage+Rx.swift"; sourceTree = "<group>"; };
|
||||
233390111C67B41400844B9D /* ReactiveStorage+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "ReactiveStorage+Rx.swift"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
|
||||
233390221C67B4EA00844B9D /* SugarRecord.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = SugarRecord.xcconfig; sourceTree = "<group>"; };
|
||||
2353E6281BED4AC00081E6E7 /* NSManagedObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSManagedObject.swift; sourceTree = "<group>"; };
|
||||
2353E6291BED4AC00081E6E7 /* NSManagedObjectContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSManagedObjectContext.swift; sourceTree = "<group>"; };
|
||||
|
@ -2,7 +2,7 @@
|
||||
import Foundation
|
||||
import CoreData
|
||||
|
||||
public class CoreDataObservable<T: NSManagedObject where T:Equatable>: Observable<T>, NSFetchedResultsControllerDelegate {
|
||||
public class CoreDataObservable<T: NSManagedObject where T:Equatable>: RequestObservable<T>, NSFetchedResultsControllerDelegate {
|
||||
|
||||
// MARK: - Attributes
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class CoreDataDefaultStorage: Storage {
|
||||
// MARK: - Public
|
||||
|
||||
#if os(iOS) || os(tvOS) || os(watchOS)
|
||||
public func observable<T: NSManagedObject where T:Equatable>(request: Request<T>) -> Observable<T> {
|
||||
public func observable<T: NSManagedObject where T:Equatable>(request: Request<T>) -> RequestObservable<T> {
|
||||
return CoreDataObservable(request: request, context: self.mainContext as! NSManagedObjectContext)
|
||||
}
|
||||
#endif
|
||||
|
@ -94,7 +94,7 @@ public class CoreDataiCloudStorage: Storage {
|
||||
|
||||
#if os(iOS) || os(tvOS) || os(watchOS)
|
||||
|
||||
public func observable<T: NSManagedObject where T:Equatable>(request: Request<T>) -> Observable<T> {
|
||||
public func observable<T: NSManagedObject where T:Equatable>(request: Request<T>) -> RequestObservable<T> {
|
||||
return CoreDataObservable(request: request, context: self.mainContext as! NSManagedObjectContext)
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ public enum ObservableChange<T> {
|
||||
case Error(NSError)
|
||||
}
|
||||
|
||||
public class Observable<T: Entity>: NSObject {
|
||||
public class RequestObservable<T: Entity>: NSObject {
|
||||
|
||||
// MARK: - Attributes
|
||||
|
||||
|
@ -2,7 +2,7 @@ import Foundation
|
||||
import ReactiveCocoa
|
||||
import Result
|
||||
|
||||
public extension Observable {
|
||||
public extension RequestObservable {
|
||||
|
||||
public func rac_observe() -> SignalProducer<ObservableChange<T>, NoError> {
|
||||
return SignalProducer { (observer, disposable) in
|
||||
|
@ -1,10 +1,10 @@
|
||||
import Foundation
|
||||
import RxSwift
|
||||
|
||||
public extension Observable {
|
||||
public extension RequestObservable {
|
||||
|
||||
public func rx_observe() -> RxSwift.Observable<ObservableChange<T>> {
|
||||
return RxSwift.Observable.create { (observer) -> Disposable in
|
||||
public func rx_observe() -> Observable<ObservableChange<T>> {
|
||||
return Observable.create { (observer) -> Disposable in
|
||||
self.observe { change in
|
||||
observer.onNext(change)
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ import RxSwift
|
||||
|
||||
public extension Storage {
|
||||
|
||||
func rx_operation(op: (context: Context, save: () -> Void) throws -> Void) -> RxSwift.Observable<Void> {
|
||||
return RxSwift.Observable.create { (observer) -> RxSwift.Disposable in
|
||||
func rx_operation(op: (context: Context, save: () -> Void) throws -> Void) -> Observable<Void> {
|
||||
return Observable.create { (observer) -> Disposable in
|
||||
do {
|
||||
try self.operation { (context, saver) throws -> Void in
|
||||
try op(context: context, save: { () -> Void in
|
||||
@ -20,15 +20,15 @@ public extension Storage {
|
||||
}
|
||||
}
|
||||
|
||||
func rx_operation(op: (context: Context) -> Void) -> RxSwift.Observable<Void> {
|
||||
func rx_operation(op: (context: Context) -> Void) -> Observable<Void> {
|
||||
return rx_operation { (context, save) in
|
||||
op(context: context)
|
||||
save()
|
||||
}
|
||||
}
|
||||
|
||||
func rx_backgroundOperation(op: (context: Context, save: () -> Void) throws -> Void) -> RxSwift.Observable<Void> {
|
||||
return RxSwift.Observable.create { (observer) -> RxSwift.Disposable in
|
||||
func rx_backgroundOperation(op: (context: Context, save: () -> Void) throws -> Void) -> Observable<Void> {
|
||||
return Observable.create { (observer) -> Disposable in
|
||||
do {
|
||||
try self.operation { (context, saver) throws in
|
||||
try op(context: context, save: { () -> Void in
|
||||
@ -44,15 +44,15 @@ public extension Storage {
|
||||
}
|
||||
}
|
||||
|
||||
func rx_backgroundOperation(op: (context: Context) throws -> Void) -> RxSwift.Observable<Void> {
|
||||
func rx_backgroundOperation(op: (context: Context) throws -> Void) -> Observable<Void> {
|
||||
return rx_backgroundOperation { (context, save) throws in
|
||||
try op(context: context)
|
||||
save()
|
||||
}
|
||||
}
|
||||
|
||||
func rx_backgroundFetch<T, U>(request: Request<T>, mapper: T -> U) -> RxSwift.Observable<[U]> {
|
||||
let observable: RxSwift.Observable<[T]> = RxSwift.Observable.create { (observer) -> RxSwift.Disposable in
|
||||
func rx_backgroundFetch<T, U>(request: Request<T>, mapper: T -> U) -> Observable<[U]> {
|
||||
let observable: Observable<[T]> = Observable.create { (observer) -> Disposable in
|
||||
let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT
|
||||
dispatch_async(dispatch_get_global_queue(priority, 0)) {
|
||||
do {
|
||||
@ -77,8 +77,8 @@ public extension Storage {
|
||||
.observeOn(MainScheduler.instance)
|
||||
}
|
||||
|
||||
func rx_fetch<T>(request: Request<T>) -> RxSwift.Observable<[T]> {
|
||||
return RxSwift.Observable.create { (observer) -> RxSwift.Disposable in
|
||||
func rx_fetch<T>(request: Request<T>) -> Observable<[T]> {
|
||||
return Observable.create { (observer) -> Disposable in
|
||||
do {
|
||||
try observer.onNext(self.fetch(request))
|
||||
observer.onCompleted()
|
||||
|
@ -1,7 +1,7 @@
|
||||
import Foundation
|
||||
import RealmSwift
|
||||
|
||||
public class RealmObservable<T: Object>: Observable<T> {
|
||||
public class RealmObservable<T: Object>: RequestObservable<T> {
|
||||
|
||||
// MARK: - Attributes
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class RealmDefaultStorage: Storage {
|
||||
}
|
||||
}
|
||||
|
||||
public func observable<T: Object>(request: Request<T>) -> Observable<T> {
|
||||
public func observable<T: Object>(request: Request<T>) -> RequestObservable<T> {
|
||||
return RealmObservable(request: request, realm: self.mainContext as! Realm)
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ class RealmDefaultStorageTests: QuickSpec {
|
||||
}
|
||||
|
||||
it("should have the correct realm") {
|
||||
expect((observable as Observable<Issue>).request) == request
|
||||
expect((observable as RequestObservable<Issue>).request) == request
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user