Skip to content

Instantly share code, notes, and snippets.

View BrandonShega's full-sized avatar

Brandon Shega BrandonShega

View GitHub Profile
@BrandonShega
BrandonShega / AsynchronousOperation.swift
Last active March 19, 2018 20:23 — forked from calebd/AsynchronousOperation.swift
Concurrent NSOperation in Swift
import Foundation
/// An abstract class that makes building simple asynchronous operations easy.
/// Subclasses must implement `execute()` to perform any work and call
/// `finish()` when they are done. All `NSOperation` work will be handled
/// automatically.
open class AsynchronousOperation: Operation {
// MARK: - Properties
import Foundation
import Result
public extension Result {
/// Constructs a success wrapping `value`, iff `value` is not nil and `error` is nil.
///
/// Constructs a failure wrapping `error`, iff `error` is not nil and `value` is nil.
///
/// Otherwise, returns nil.