Skip to content

Delete funny custom operators. #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,50 +100,6 @@ task.progress { progress in
}
```

### Using custom operator

You can even use custom operators for chaining! :dizzy:

- `task ~ {...}` = `task.progress { progress in ...}`
- `task >>> {...}` = `task.then { value, errorInfo in ...}` (fulfilled & rejected)
- `task *** {...}` = `task.then { value in ...}` (fulfilled only)
- `task !!! {...}` = `task.catch { errorInfo in ...}` (rejected only)

```swift
task ~ { (progress: Float) in

println("progress = \(progress)")

} *** { (value: String) -> String in

XCTAssertEqual(value, "OK")
return "Now OK"

} !!! { (error: ErrorString?, isCancelled: Bool) -> String in

XCTAssertEqual(error!, "ERROR")
return "Now RECOVERED"

} >>> { (value: String?, errorInfo: Task.ErrorInfo?) -> Task in

println("value = \(value)") // either "Now OK" or "Now RECOVERED"

XCTAssertTrue(value!.hasPrefix("Now"))
XCTAssertTrue(errorInfo == nil)

return Task(error: "ABORT")

} >>> { (value: String?, errorInfo: Task.ErrorInfo?) -> Void in

println("errorInfo = \(errorInfo)")

XCTAssertTrue(value == nil)
XCTAssertEqual(errorInfo!.error!, "ABORT")
expect.fulfill()

}
```

For more examples, please see XCTest cases.


Expand Down
6 changes: 0 additions & 6 deletions SwiftTask.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/* Begin PBXBuildFile section */
1F0E284019C1DEA0005EF467 /* Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F0E282319C1DEA0005EF467 /* Async.swift */; };
1F2024FF19AD97A700DE0495 /* CustomOperatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F2024FE19AD97A700DE0495 /* CustomOperatorTests.swift */; };
1F20250219ADA8FD00DE0495 /* BasicTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F20250119ADA8FD00DE0495 /* BasicTests.swift */; };
1F24C72B19D0688800C2FDC7 /* SwiftTask.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 48CD5A0C19AEE3570042B9F1 /* SwiftTask.framework */; };
1F46DEDA199EDF1000F97868 /* SwiftTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F46DED9199EDF1000F97868 /* SwiftTask.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand All @@ -19,7 +18,6 @@
4822F0DC19D00B2300F5F572 /* _TestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F46DEFC199EE2C200F97868 /* _TestCase.swift */; };
4822F0DD19D00B2300F5F572 /* BasicTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F20250119ADA8FD00DE0495 /* BasicTests.swift */; };
4822F0DE19D00B2300F5F572 /* SwiftTaskTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F46DEE3199EDF1000F97868 /* SwiftTaskTests.swift */; };
4822F0DF19D00B2300F5F572 /* CustomOperatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F2024FE19AD97A700DE0495 /* CustomOperatorTests.swift */; };
4822F0E019D00B2300F5F572 /* RetainCycleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48511C5A19C17563002FE03C /* RetainCycleTests.swift */; };
4822F0E319D00B3100F5F572 /* Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F0E282319C1DEA0005EF467 /* Async.swift */; };
48511C5B19C17563002FE03C /* RetainCycleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48511C5A19C17563002FE03C /* RetainCycleTests.swift */; };
Expand Down Expand Up @@ -62,7 +60,6 @@

/* Begin PBXFileReference section */
1F0E282319C1DEA0005EF467 /* Async.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Async.swift; sourceTree = "<group>"; };
1F2024FE19AD97A700DE0495 /* CustomOperatorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomOperatorTests.swift; sourceTree = "<group>"; };
1F20250119ADA8FD00DE0495 /* BasicTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicTests.swift; sourceTree = "<group>"; };
1F46DED4199EDF1000F97868 /* SwiftTask.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftTask.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1F46DED8199EDF1000F97868 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -169,7 +166,6 @@
1F46DEFC199EE2C200F97868 /* _TestCase.swift */,
1F20250119ADA8FD00DE0495 /* BasicTests.swift */,
1F46DEE3199EDF1000F97868 /* SwiftTaskTests.swift */,
1F2024FE19AD97A700DE0495 /* CustomOperatorTests.swift */,
48511C5A19C17563002FE03C /* RetainCycleTests.swift */,
1F5FA35619A374E600975FB9 /* AlamofireTests.swift */,
1F46DEE1199EDF1000F97868 /* Supporting Files */,
Expand Down Expand Up @@ -447,7 +443,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1F2024FF19AD97A700DE0495 /* CustomOperatorTests.swift in Sources */,
1F20250219ADA8FD00DE0495 /* BasicTests.swift in Sources */,
1F0E284019C1DEA0005EF467 /* Async.swift in Sources */,
1F6A8CA319A4E4F200369A5D /* SwiftTaskTests.swift in Sources */,
Expand All @@ -462,7 +457,6 @@
files = (
4822F0DE19D00B2300F5F572 /* SwiftTaskTests.swift in Sources */,
4822F0DD19D00B2300F5F572 /* BasicTests.swift in Sources */,
4822F0DF19D00B2300F5F572 /* CustomOperatorTests.swift in Sources */,
4822F0E319D00B3100F5F572 /* Async.swift in Sources */,
4822F0DC19D00B2300F5F572 /* _TestCase.swift in Sources */,
4822F0E019D00B2300F5F572 /* RetainCycleTests.swift in Sources */,
Expand Down
51 changes: 0 additions & 51 deletions SwiftTask/SwiftTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -635,57 +635,6 @@ extension Task
}
}

//--------------------------------------------------
// MARK: - Custom Operators
//--------------------------------------------------

// then (fulfilled & rejected)
infix operator >>> { associativity left }

public func >>> <P, V1, V2, E>(left: Task<P, V1, E>, right: (V1?, (E?, Bool)?) -> V2) -> Task<P, V2, E>
{
return left.then(right)
}

public func >>> <P1, V1, P2, V2, E>(left: Task<P1, V1, E>, right: (V1?, (E?, Bool)?) -> Task<P2, V2, E>) -> Task<P2, V2, E>
{
return left.then(right)
}

// then (fulfilled only)
infix operator *** { associativity left }

public func *** <P, V1, V2, E>(left: Task<P, V1, E>, right: V1 -> V2) -> Task<P, V2, E>
{
return left.then(right)
}

public func *** <P1, V1, P2, V2, E>(left: Task<P1, V1, E>, right: V1 -> Task<P2, V2, E>) -> Task<P2, V2, E>
{
return left.then(right)
}

// catch (rejected only)
infix operator !!! { associativity left }

public func !!! <P, V, E>(left: Task<P, V, E>, right: (E?, Bool) -> V) -> Task<P, V, E>
{
return left.catch(right)
}

public func !!! <P, V, E>(left: Task<P, V, E>, right: (E?, Bool) -> Task<P, V, E>) -> Task<P, V, E>
{
return left.catch(right)
}

// progress
infix operator ~ { associativity left }

public func ~ <P, V, E>(left: Task<P, V, E>, right: P -> Void) -> Task<P, V, E>
{
return left.progress(right)
}

//--------------------------------------------------
// MARK: - Utility
//--------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions SwiftTaskTests/BasicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ class BasicTests: _TestCase

}

task ~ { (progress: Float) in
task.progress { (progress: Float) in

println("progress = \(progress)")

} *** { (value: String) -> String in // then(onFulfilled)
}.then { (value: String) -> String in // then(onFulfilled)

XCTAssertEqual(value, "OK")
return "Now OK"

} !!! { (error: ErrorString?, isCancelled: Bool) -> String in // catch(onRejected)
}.catch { (error: ErrorString?, isCancelled: Bool) -> String in // catch(onRejected)

XCTAssertEqual(error!, "ERROR")
return "Now RECOVERED"

} >>> { (value: String?, errorInfo: Task.ErrorInfo?) -> Task in // then(onFulfilled+onRejected)
}.then { (value: String?, errorInfo: Task.ErrorInfo?) -> Task in // then(onFulfilled+onRejected)

println("value = \(value)") // either "Now OK" or "Now RECOVERED"

Expand All @@ -59,7 +59,7 @@ class BasicTests: _TestCase

return Task(error: "ABORT")

} >>> { (value: String?, errorInfo: Task.ErrorInfo?) -> Void in // then(onFulfilled+onRejected)
}.then { (value: String?, errorInfo: Task.ErrorInfo?) -> Void in // then(onFulfilled+onRejected)

println("errorInfo = \(errorInfo)")

Expand Down
138 changes: 0 additions & 138 deletions SwiftTaskTests/CustomOperatorTests.swift

This file was deleted.