This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Combine | |
var list = ["A", "B", "C"] | |
let cancellable = list.publisher | |
.collect() | |
.sink { completion in | |
print("Completed with \(completion)") | |
} receiveValue: { value in | |
print(value) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func trace(msg string) string { | |
fmt.Printf("BEGIN %s\n", msg) | |
return msg | |
} | |
func untrace(msg string) string { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import RxSwift | |
import RxCocoa | |
class SimpleTableViewExampleViewController : ViewController, UITableViewDelegate { | |
@IBOutlet weak var tableView: UITableView! | |
let itemsObservable = BehaviorRelay(value: (0..<5).map { "\($0)" }) | |
@objc func add() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SRKTransaction.transaction({ | |
SharkUser.query().fetch().removeAll() | |
SharkCommit.query().fetch().removeAll() | |
}, withRollback: {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try! realm.write { | |
realm.deleteAll() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for _ in [0...Globals.UPDATE_REPEAT] { | |
SRKTransaction.transaction({ | |
self.commit.message = randomString(length: self.commit.message.characters.count) | |
self.commit.commit() // this happened to be confusing :P (commit object is committing the change) | |
}, withRollback: {}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for _ in [0...Globals.UPDATE_REPEAT] { | |
try! realm.write { | |
commit.message = randomString(length: commit.message.characters.count) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for _ in [0...Globals.RANDOM_SELECT_REPEAT] { | |
_ = realm.objects(RealmUser.self).filter("id = %@", user.id).first!.commits[Int(arc4random_uniform(UInt32(max)))] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for _ in [0...Globals.RANDOM_SELECT_REPEAT] { | |
let index = Int(arc4random_uniform(UInt32(max))) | |
_ = SharkCommit.query().where(withFormat: "user = %@", withParameters: [self.user]).fetch()[index] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for _ in [0...Globals.SELECT_COUNT_REPEAT] { | |
_ = SharkUser.query().fetch().count | |
} |
NewerOlder