I hereby claim:
- I am groue on github.
- I am groue (https://keybase.io/groue) on keybase.
- I have a public key whose fingerprint is EDC5 4AA4 0D3A 475A DB0E 78B4 2A35 40DD A1C7 3F08
To claim this, I am signing this object:
import Foundation | |
/// To create an operation: | |
/// | |
/// 1. Subclass AsynchronousOperation, override main, and eventually cancel the | |
/// operation, or set result to a non-nil value. | |
/// | |
/// 2. Use makeOperation { op in ... }, and eventually cancel the | |
/// operation, or set result to a non-nil value. | |
open class AsynchronousOperation<Output, Failure: Error>: Operation { |
import Combine | |
import Foundation | |
/// A thread-safe store for cancellables which addresses usability pain points | |
/// with stock Combine apis. | |
/// | |
/// ## Thread-safe storage of cancellables | |
/// | |
/// let cancelBag = CancelBag() | |
/// cancellable.store(in: cancelBag) |
import Combine | |
/// A publisher that delivers values to its downstream subscriber on a | |
/// specific scheduler. | |
/// | |
/// Unlike Combine's Publishers.ReceiveOn, ReceiveValuesOn only re-schedule | |
/// values and completion. It does not re-schedule subscription. | |
struct ReceiveValuesOn<Upstream: Publisher, Context: Scheduler>: Publisher { | |
typealias Output = Upstream.Output | |
typealias Failure = Upstream.Failure |
//: # Toward Enum Key Paths: a Protocol Hierarchy for Read-Only Key Paths | |
//: | |
//: This playground is an experiment for a protocol hierarchy of read-only | |
//: key paths that can handle both throwing and non-throwing getters. | |
//: | |
//: Since the Swift language has no support for throwing subscripts, we'll | |
//: perform our experiments with a very simplified setup that involves a single | |
//: getter function. | |
//: | |
//: ## The Protocol Hierarchy |
// A replication of the convenience fetching methods of FetchableRecord, | |
// built for another record protocol: ContextFetchableRecord | |
protocol ContextFetchableRecord { | |
associatedtype Context | |
init(row: Row, context: Context) | |
} | |
extension ContextFetchableRecord { | |
// To run this playground, select and build the GRDBOSX scheme. | |
// | |
// This sample code shows how to use GRDB to synchronize a database table | |
// with a JSON payload. We use as few SQL queries as possible: | |
// | |
// - Only one SELECT query. | |
// - One query per insert, delete, and update. | |
// - Useless UPDATE statements are avoided. | |
import Foundation |
I hereby claim:
To claim this, I am signing this object:
/// A ReadWriteBox grants multiple readers and single-writer guarantees on a value. | |
final class ReadWriteBox<T> { | |
var value: T { | |
get { return read { $0 } } | |
set { write { $0 = newValue } } | |
} | |
init(_ value: T) { | |
self._value = value | |
self.queue = DispatchQueue(label: "ReadWriteBox", attributes: [.concurrent]) |
class PersonsViewController: UITableViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Configure the navigation bar | |
navigationItem.rightBarButtonItems = [ | |
UIBarButtonItem( | |
barButtonSystemItem: .Add, | |
target: self, | |
action: #selector(PersonsViewController.addPerson(_:))), |