Skip to content

Commit

Permalink
Fix an error related to escaping arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
fmo91 committed Jan 29, 2017
1 parent 4172451 commit 2494d39
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions Microfutures/Classes/Microfutures.swift
Expand Up @@ -15,10 +15,8 @@ public enum Result<T> {

public struct Future<T> {
public typealias ResultType = Result<T>
public typealias Completion = (ResultType) -> ()
public typealias AsyncOperation = (Completion) -> ()

private let operation: AsyncOperation
private let operation: ( @escaping (ResultType) -> ()) -> ()

public init(result: ResultType) {
self.init(operation: { completion in
Expand All @@ -34,11 +32,11 @@ public struct Future<T> {
self.init(result: .failure(error))
}

public init(operation: @escaping AsyncOperation) {
public init(operation: @escaping ( @escaping (ResultType) -> ()) -> ()) {
self.operation = operation
}

fileprivate func then(_ completion: Completion) {
fileprivate func then(_ completion: @escaping (ResultType) -> ()) {
self.operation() { result in
completion(result)
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -6,7 +6,7 @@
[![Platform](https://img.shields.io/cocoapods/p/Microfutures.svg?style=flat)](http://cocoapods.org/pods/Microfutures)

## Introduction
Microfutures is a very microlibrary (60 LOCs) that implements a simple Futures/Promises flow. It also has a similar public interface to [RxSwift](https://github.com/ReactiveX/RxSwift).
Microfutures is a very small library (60 LOCs) that implements a simple Futures/Promises flow. It also has a similar public interface to [RxSwift](https://github.com/ReactiveX/RxSwift).

## What is a future?
A future is a representation of a value that hasn't been already generated. The best use case of Futures is to simplify an asynchronous flow. Instead of writing nested callbacks, you can chain futures, turning that awful callback hell into a beautiful functional pipeline.
Expand Down

0 comments on commit 2494d39

Please sign in to comment.