You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/SnapshotTesting/Snapshotting.swift
+23-9Lines changed: 23 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -46,8 +46,31 @@ public struct Snapshotting<Value, Format> {
46
46
}
47
47
}
48
48
49
+
/// Transforms a strategy on `Value`s into a strategy on `NewValue`s through a function `(NewValue) -> Value`.
50
+
///
51
+
/// This is the most important operation for transforming existing strategies into new strategies. It allows you to transform a `Snapshotting<Value, Format>` into a `Snapshotting<NewValue, Format>` by pulling it back along a function `(NewValue) -> Value`. Notice that the function must go in in the direction `(NewValue) -> Value` even though we are transforming in the other direction `(Snapshotting<Value, Format>) -> Snapshotting<NewValue, Format>`.
52
+
///
53
+
/// A simple example of this is to `pullback` the snapshot strategy on `UIView`s to work on `UIViewController`s:
54
+
///
55
+
/// let strategy = Snapshotting<UIView, UIImage>.image.pullback { (vc: UIViewController) in
56
+
/// return vc.view
57
+
/// }
58
+
///
59
+
/// Here we took the strategy that snapshots `UIView`s as `UIImage`s and pulled it back to work on `UIViewController`s by using the function `(UIViewController) -> UIView` that simply plucks the view out of the controller.
60
+
///
61
+
/// Nearly every snapshot strategy provided in this library is a pullback of some base strategy, which shows just how important this operation is.
62
+
///
63
+
/// - Parameters:
64
+
/// - transform: A transform function from `NewValue` into `Value`.
/// Transforms a strategy on `Value`s into a strategy on `NewValue`s through a function `(NewValue) -> Async<Value>`.
50
71
///
72
+
/// See the documention of `pullback` for a full description of how pullbacks works. This operation differs from `pullback` in that it allows you to use a transformation `(NewValue) -> Async<Value>`, which is necessary when your transformation needs to perform some asynchronous work.
73
+
///
51
74
/// - Parameters:
52
75
/// - transform: A transform function from `NewValue` into `Async<Value>`.
53
76
/// - otherValue: A value to be transformed.
@@ -67,15 +90,6 @@ public struct Snapshotting<Value, Format> {
67
90
}
68
91
}
69
92
}
70
-
71
-
/// Transforms a strategy on `Value`s into a strategy on `NewValue`s through a function `(NewValue) -> Value`.
72
-
///
73
-
/// - Parameters:
74
-
/// - transform: A transform function from `NewValue` into `Value`.
0 commit comments