Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions Example/Podfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
use_frameworks!

target 'RxRealmDataSources_Example' do
abstract_target 'Demo' do
pod 'RealmSwift'
pod 'RxSwift'
pod 'RxCocoa'
pod 'RxRealm'
pod 'RxRealmDataSources', :path => '../'

target 'RxRealmDataSources_Tests' do
inherit! :search_paths
target 'RxRealmDataSources_Example' do
platform :ios, '9.0'
end

target 'RxRealmDataSources_MacExample' do
platform :osx, '10.12'
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
target 'RxRealmDataSources_Tests'
end
329 changes: 295 additions & 34 deletions Example/RxRealmDataSources.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Example/RxRealmDataSources/CollectionViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CollectionViewController: UIViewController {
}

// RxRealm to get Observable<Results>
let realm = try! Realm(configuration: DataRandomizer.realmConfig)
let realm = try! Realm(configuration: data.config)
let laps = Observable.changesetFrom(realm.objects(Timer.self).first!.laps)
.share()

Expand Down
34 changes: 24 additions & 10 deletions Example/RxRealmDataSources/DataRandomizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import Dispatch
import RealmSwift
import RxSwift

Expand All @@ -19,23 +20,36 @@ extension Int {
class DataRandomizer {

private let bag = DisposeBag()
static let realmConfig = DataRandomizer.config()

static func config() -> Realm.Configuration {
lazy var config: Realm.Configuration = {
var config = Realm.Configuration.defaultConfiguration
config.deleteRealmIfMigrationNeeded = true
let realm = try! Realm(configuration: config)
config.inMemoryIdentifier = UUID().uuidString
return config
}()

private lazy var realm: Realm = {
let realm: Realm
do {
realm = try Realm(configuration: self.config)
return realm
}
catch let e {
print(e)
fatalError()
}
}()

init() {
reset()
}

func reset() {
try! realm.write {
realm.deleteAll()
realm.add(Timer())
}
return config
}

private lazy var realm: Realm = {
return try! Realm(configuration: DataRandomizer.realmConfig)
}()

private func insertRow() {
try! realm.write {
let timerLaps = realm.objects(Timer.self).first!.laps
Expand Down Expand Up @@ -77,7 +91,7 @@ class DataRandomizer {
})
.addDisposableTo(bag)

Observable<Int>.interval(1, scheduler: MainScheduler.instance)
Observable<Int>.interval(1.2, scheduler: MainScheduler.instance)
.subscribe(onNext: {[weak self] _ in
self?.deleteRow()
})
Expand Down
2 changes: 1 addition & 1 deletion Example/RxRealmDataSources/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ViewController: UIViewController {
}

// RxRealm to get Observable<Results>
let realm = try! Realm(configuration: DataRandomizer.realmConfig)
let realm = try! Realm(configuration: data.config)
let laps = Observable.changesetFrom(realm.objects(Timer.self).first!.laps)
.share()

Expand Down
19 changes: 19 additions & 0 deletions Example/RxRealmDataSources_MacExample/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// AppDelegate.swift
// RxRealmDataSources_MacExample
//
// Created by Marin Todorov on 12/30/16.
// Copyright © 2016 CocoaPods. All rights reserved.
//

import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

func applicationDidFinishLaunching(_ aNotification: Notification) {
}

func applicationWillTerminate(_ aNotification: Notification) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"images" : [
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading