Skip to content
This repository was archived by the owner on Aug 8, 2024. It is now read-only.

Commit bc3b7a8

Browse files
committed
Removes operator, starts updating README, MIGRATING and CHANGELOG
1 parent 46c7121 commit bc3b7a8

31 files changed

+145
-503
lines changed

CHANGELOG.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
## 0.9
44

55
**Breaking changes**
6-
- Swift 2.3 support
7-
- `batchGetAll` has been deprecated and replaced with a reified `allBatch` (see **New features**)
6+
- Swift 3.0 support (for Swift 2.3 use specific commit `5d354c829d766568f164c386c59de21357b5ccff` instead)
7+
- `batchGetAll` has been removed and replaced with a reified `allBatch` (see **New features**)
8+
- All deprecated functions have been removed
9+
- All custom operators have been removed in favor of their function counterparts
10+
- macOS and tvOS support has been temporarily dropped and will be probably re-added in the future
811
- `set` method on `CacheLevel` now returns a `Future` enabling error-handling and progress-tracking of `set` calls.
912

1013
**New Features**

Carlos/CacheProvider+iOS.swift

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ extension CacheProvider {
99
- returns: An initialized and configured CacheLevel that takes NSURL keys and stores UIImage values. Network requests are pooled for efficiency. Keep in mind that calling this method twice returns two different instances. You should take care of retaining the result or use `sharedImageCache` instead
1010
*/
1111
public static func imageCache() -> BasicCache<URL, UIImage> {
12-
return MemoryCacheLevel<URL, UIImage>() >>> DiskCacheLevel<URL, UIImage>() >>> (NetworkFetcher().pooled() =>> ImageTransformer())
12+
return MemoryCacheLevel<URL, UIImage>()
13+
.compose(DiskCacheLevel<URL, UIImage>())
14+
.compose(
15+
NetworkFetcher()
16+
.pooled()
17+
.transformValues(ImageTransformer())
18+
)
1319
}
1420
}

Carlos/CacheProvider.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ public final class CacheProvider {
1414
- returns: An initialized and configured CacheLevel that takes NSURL keys and stores NSData values. Network requests are pooled for efficiency. Keep in mind that calling this method twice returns two different instances. You should take care of retaining the result or use `sharedDataCache` instead
1515
*/
1616
public static func dataCache() -> BasicCache<URL, NSData> {
17-
return MemoryCacheLevel<URL, NSData>() >>> (DiskCacheLevel<URL, NSData>() >>> NetworkFetcher()).pooled()
17+
return MemoryCacheLevel<URL, NSData>()
18+
.compose(
19+
DiskCacheLevel<URL, NSData>().compose(NetworkFetcher())
20+
.pooled()
21+
)
1822
}
1923

2024
/**
2125
- returns: An initialized and configured CacheLevel that takes NSURL keys and stores JSON values in the form of AnyObject. Network requests are pooled for efficiency. Keep in mind that calling this method twice returns two different instances. You should take care of retaining the result or use `sharedJSONCache` instead
2226
*/
2327
public static func JSONCache() -> BasicCache<URL, AnyObject> {
24-
return dataCache() =>> JSONTransformer()
28+
return dataCache().transformValues(JSONTransformer())
2529
}
2630
}

Carlos/Carlos.swift

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ internal func wrapClosureIntoOneWayTransformer<A, B>(_ transformerClosure: @esca
1414
return OneWayTransformationBox(transform: transformerClosure)
1515
}
1616

17-
infix operator =>>: MultiplicationPrecedence
18-
1917
/// An abstraction for a generic cache level
2018
public protocol CacheLevel {
2119
/// A typealias for the key the cache level accepts

Carlos/Composed.swift

-14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import Foundation
22
import PiedPiper
33

4-
infix operator >>>: AdditionPrecedence
5-
64
extension CacheLevel {
75

86
/**
@@ -46,15 +44,3 @@ extension CacheLevel {
4644
)
4745
}
4846
}
49-
50-
/**
51-
Composes two cache levels
52-
53-
- parameter firstCache: The first cache level
54-
- parameter secondCache: The second cache level
55-
56-
- returns: A new cache level that is the result of the composition of the two cache levels
57-
*/
58-
public func >>><A: CacheLevel, B: CacheLevel>(firstCache: A, secondCache: B) -> BasicCache<A.KeyType, A.OutputType> where A.KeyType == B.KeyType, A.OutputType == B.OutputType {
59-
return firstCache.compose(secondCache)
60-
}

Carlos/ComposedOneWayTransformer.swift

-12
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,3 @@ extension OneWayTransformer {
1313
return OneWayTransformationBox(transform: self.transform >>> transformer.transform)
1414
}
1515
}
16-
17-
/**
18-
Composes two OneWayTransformers
19-
20-
- parameter firstTransformer: The first transformer to apply
21-
- parameter secondTransformer: The second transformer to apply
22-
23-
- returns: A new OneWayTransformer that is the result of the composition of the two OneWayTransformers
24-
*/
25-
public func >>><A: OneWayTransformer, B: OneWayTransformer>(firstTransformer: A, secondTransformer: B) -> OneWayTransformationBox<A.TypeIn, B.TypeOut> where B.TypeIn == A.TypeOut {
26-
return firstTransformer.compose(secondTransformer)
27-
}

Carlos/ComposedTwoWayTransformer.swift

-12
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,3 @@ extension TwoWayTransformer {
1616
)
1717
}
1818
}
19-
20-
/**
21-
Composes two TwoWayTransformers
22-
23-
- parameter firstTransformer: The first TwoWayTransformer to apply
24-
- parameter secondTransformer: The second TwoWayTransformer to apply
25-
26-
- returns: A new TwoWayTransformer that is the result of the composition of the two TwoWayTransformers
27-
*/
28-
public func >>><A: TwoWayTransformer, B: TwoWayTransformer>(firstTransformer: A, secondTransformer: B) -> TwoWayTransformationBox<A.TypeIn, B.TypeOut> where B.TypeIn == A.TypeOut {
29-
return firstTransformer.compose(secondTransformer)
30-
}

Carlos/Conditioned.swift

-16
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import Foundation
22
import PiedPiper
33

4-
infix operator <?>: MultiplicationPrecedence
5-
64
extension CacheLevel {
75

86
/**
@@ -65,17 +63,3 @@ extension TwoWayTransformer {
6563
)
6664
}
6765
}
68-
69-
/**
70-
Wraps a CacheLevel with a boolean condition on the key that controls when a get call should fail unconditionally
71-
72-
- parameter condition: The condition closure that takes a key and returns true if the key can be fetched, or false if the request should fail unconditionally. The closure can also pass a specific error in case it wants to explicitly communicate why it failed. The condition can be asynchronous and has to return a Future<Bool>
73-
- parameter cache: The cache level you want to decorate
74-
75-
- returns: A new BasicCache that will check for the condition before every get is dispatched to the decorated cache level
76-
77-
The condition doesn't apply to the set, clear, onMemoryWarning calls
78-
*/
79-
public func <?><A: CacheLevel>(condition: @escaping (A.KeyType) -> Future<Bool>, cache: A) -> BasicCache<A.KeyType, A.OutputType> {
80-
return cache.conditioned(condition)
81-
}

Carlos/ConditionedOutputProcessing.swift

-32
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import Foundation
22
import PiedPiper
33

4-
infix operator ?>>: MultiplicationPrecedence
5-
64
extension Future {
75

86
/**
@@ -43,33 +41,3 @@ extension CacheLevel {
4341
)
4442
}
4543
}
46-
47-
/**
48-
Adds a conditioned post-processing step to the results of a fetch closure
49-
50-
As usual, if the transformation fails, the fetch will also fail
51-
52-
- parameter fetchClosure: The closure that will take care of fetching the values
53-
- parameter conditionedTransformer: The transformer that will be applied to every successful fetch. The transformer gets the key used for the request (where it can apply its condition on) and the fetched value, and has to return the same type of the value.
54-
The transformation won't be applied when setting values on the cache level, also considering fetch closures don't have a set operation.
55-
56-
- returns: A CacheLevel that incorporates the post-processing step after the fetch
57-
*/
58-
public func ?>><A, B, T: ConditionedOneWayTransformer>(fetchClosure: @escaping (_ key: A) -> Future<B>, conditionedTransformer: T) -> BasicCache<A, B> where T.KeyType == A, T.TypeIn == B, T.TypeOut == B {
59-
return wrapClosureIntoFetcher(fetchClosure).conditionedPostProcess(conditionedTransformer)
60-
}
61-
62-
/**
63-
Adds a conditioned post-processing step to the get results of a given CacheLevel
64-
65-
As usual, if the transformation fails, the get request will also fail
66-
67-
- parameter cache: The CacheLevel you want to apply the post-processing step to
68-
- parameter conditionedTransformer: The transformer that will be applied to every successful fetch. The transformer gets the key used for the request (where it can apply its condition on) and the fetched value, and has to return the same type of the value.
69-
The transformation won't be applied when setting values on the cache level, also considering fetch closures don't have a set operation.
70-
71-
- returns: A transformed CacheLevel that incorporates the post-processing step
72-
*/
73-
public func ?>><A: CacheLevel, T: ConditionedOneWayTransformer>(cache: A, conditionedTransformer: T) -> BasicCache<A.KeyType, A.OutputType> where T.KeyType == A.KeyType, T.TypeIn == A.OutputType, T.TypeOut == A.OutputType {
74-
return cache.conditionedPostProcess(conditionedTransformer)
75-
}

Carlos/ConditionedValueTransformation.swift

-13
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,3 @@ extension CacheLevel {
4848
}
4949
}
5050

51-
/**
52-
Adds a conditioned value transformation step to a given CacheLevel
53-
54-
As usual, if the transformation fails, the get (or set) request will also fail
55-
56-
- parameter cache: The CacheLevel you want to apply the value transformation step to
57-
- parameter conditionedTransformer: The transformer that will be applied to every get or set. The transformer gets the key used for the request (where it can apply its condition on) and the fetched value or the value to set, and returns a future with the transformed value.
58-
59-
- returns: A transformed CacheLevel that incorporates the value transformation step
60-
*/
61-
public func ?>><A: CacheLevel, T: ConditionedTwoWayTransformer>(cache: A, conditionedTransformer: T) -> BasicCache<A.KeyType, T.TypeOut> where T.KeyType == A.KeyType, T.TypeIn == A.OutputType {
62-
return cache.conditionedValueTransformation(transformer: conditionedTransformer)
63-
}

Carlos/Dispatched.swift

-14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import Foundation
22
import PiedPiper
33

4-
infix operator ~>>
5-
64
extension CacheLevel {
75
/**
86
Dispatches all the operations of this CacheLevel on the given GCD queue
@@ -42,15 +40,3 @@ extension CacheLevel {
4240
)
4341
}
4442
}
45-
46-
/**
47-
Dispatches all the operations of a given CacheLevel on the given GCD queue
48-
49-
- parameter lhs: The CacheLevel you want to dispatch on the given GCD queue
50-
- parameter rhs: The queue you want to dispatch all the operations (get, set, clear, onMemoryWarning) of the CacheLevel on
51-
52-
- returns: A new CacheLevel that dispatches all the operations on the given GCD queue
53-
*/
54-
public func ~>><A: CacheLevel>(lhs: A, rhs: DispatchQueue) -> BasicCache<A.KeyType, A.OutputType> {
55-
return lhs.dispatch(rhs)
56-
}

Carlos/FetcherValueTransformation.swift

-14
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,3 @@ extension Fetcher {
2020
)
2121
}
2222
}
23-
24-
/**
25-
Applies a transformation to a fetcher
26-
The transformation works by changing the type of the value the fetcher returns when succeeding
27-
Use this transformation when you store a value type but want to mount the fetcher in a pipeline that works with other value types
28-
29-
- parameter fetcher: The fetcher you want to transform
30-
- parameter transformer: The transformation you want to apply
31-
32-
- returns: A new fetcher result of the transformation of the original fetcher
33-
*/
34-
public func =>><A: Fetcher, B: OneWayTransformer>(fetcher: A, transformer: B) -> BasicFetcher<A.KeyType, B.TypeOut> where A.OutputType == B.TypeIn {
35-
return fetcher.transformValues(transformer)
36-
}

Carlos/KeyTransformation.swift

-14
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,3 @@ extension CacheLevel {
2727
)
2828
}
2929
}
30-
31-
/**
32-
Applies a transformation to a cache level
33-
The transformation works by changing the type of the key the cache accepts
34-
Use this transformation when you use a domain specific key or a wrapper key that contains several values every cache level can choose from
35-
36-
- parameter cache: The cache level you want to transform
37-
- parameter transformer: The transformation you want to apply
38-
39-
- returns: A new cache level result of the transformation of the original cache level
40-
*/
41-
public func =>><A: CacheLevel, B: OneWayTransformer>(transformer: B, cache: A) -> BasicCache<B.TypeIn, A.OutputType> where A.KeyType == B.TypeOut {
42-
return cache.transformKeys(transformer)
43-
}

Carlos/PostProcess.swift

-16
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import Foundation
22
import PiedPiper
33

4-
infix operator ~>>: MultiplicationPrecedence
5-
64
extension CacheLevel {
75

86
/**
@@ -25,17 +23,3 @@ extension CacheLevel {
2523
)
2624
}
2725
}
28-
29-
/**
30-
Adds a post-processing step to the get results of a CacheLevel
31-
32-
As usual, if the transformation fails, the get request will also fail
33-
34-
- parameter cache: The CacheLevel you want to decorate
35-
- parameter transformer: The OneWayTransformer that will be applied to every successful result of the CacheLevel. The transformer has to return the same type of the input type, and the transformation won't be applied when setting values on the cache level.
36-
37-
- returns: A transformed CacheLevel that incorporates the post-processing step
38-
*/
39-
public func ~>><A: CacheLevel, B: OneWayTransformer>(cache: A, transformer: B) -> BasicCache<A.KeyType, A.OutputType> where A.OutputType == B.TypeIn, B.TypeIn == B.TypeOut {
40-
return cache.postProcess(transformer)
41-
}

Carlos/ValueTransformation.swift

-14
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,3 @@ extension CacheLevel {
4242
)
4343
}
4444
}
45-
46-
/**
47-
Applies a transformation to a cache level
48-
The transformation works by changing the type of the value the cache returns when succeeding
49-
Use this transformation when you store a value type but want to mount the cache in a pipeline that works with other value types
50-
51-
- parameter cache: The cache level you want to transform
52-
- parameter transformer: The transformation you want to apply
53-
54-
- returns: A new cache result of the transformation of the original cache
55-
*/
56-
public func =>><A: CacheLevel, B: TwoWayTransformer>(cache: A, transformer: B) -> BasicCache<A.KeyType, B.TypeOut> where A.OutputType == B.TypeIn {
57-
return cache.transformValues(transformer)
58-
}

MIGRATING.md

+21
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
## Migrating from 0.8 to 0.9
2+
3+
### Swift 3 support
4+
5+
Please make sure to convert all usages of `Carlos` APIs to the Swift 3 counterparts. In most cases there won't be a big syntactic difference.
6+
7+
### Deprecated functions
8+
9+
All deprecated functions have been removed. This were of 2 types:
10+
11+
- Global functions
12+
- Functions taking fetch closures or transformation closures
13+
14+
For the first type, just use the corresponding protocol extension function.
15+
16+
For the second type, please use `BasicFetcher` instead of fetch closures, and explicit `OneWayTransformationBox` instances instead of transformation closures.
17+
18+
### Custom operators
19+
20+
All custom operators have been removed. Please use the corresponding protocol extension functions instead. This may require some reordering of the objects.
21+
122
## Migrating from 0.7 to 0.8
223

324
### `Promise` now has only an empty `init`.

0 commit comments

Comments
 (0)