@@ -12,23 +12,17 @@ public struct StaticStorePreviewContext {
12
12
}
13
13
14
14
public func makeStateAccessor< State> ( state: State ) -> StateAccessor < State > {
15
- StateAccessor (
16
- state: state,
17
- sendValue: { _ in }
18
- )
15
+ . constant( state: state)
19
16
}
20
17
21
18
public func makeActionModel< State, Action> (
22
19
state: State
23
20
) -> ActionModel < State , Action > {
24
- ActionModel (
25
- accessor: makeStateAccessor ( state: state) ,
26
- sendAction: makeSink ( of: Action . self) . send
27
- )
21
+ . constant( state: state)
28
22
}
29
23
}
30
24
31
- extension Store {
25
+ public extension Store {
32
26
/// Generates a static store for previews.
33
27
///
34
28
/// Previews generated with this method are static and do not update state. To generate a
@@ -38,15 +32,15 @@ extension Store {
38
32
/// - Parameter makeModel: A closure to create the store's model. The provided `context` param
39
33
/// is a convenience to generate dummy sinks and state accessors.
40
34
/// - Returns: A store for previews.
41
- public static func preview(
35
+ static func preview(
42
36
makeModel: ( StaticStorePreviewContext ) -> Model
43
37
) -> Store {
44
38
let context = StaticStorePreviewContext ( )
45
39
let model = makeModel ( context)
46
40
let ( store, _) = make ( model: model)
47
41
return store
48
42
}
49
-
43
+
50
44
/// Generates a static store for previews.
51
45
///
52
46
/// Previews generated with this method are static and do not update state. To generate a
@@ -55,14 +49,14 @@ extension Store {
55
49
///
56
50
/// - Parameter state: The state of the view.
57
51
/// - Returns: A store for previews.
58
- public static func preview< State, Action> (
52
+ static func preview< State, Action> (
59
53
state: State
60
54
) -> Store < ActionModel < State , Action > > where Model == ActionModel < State , Action > {
61
55
preview { context in
62
56
context. makeActionModel ( state: state)
63
57
}
64
58
}
65
-
59
+
66
60
/// Generates a static store for previews.
67
61
///
68
62
/// Previews generated with this method are static and do not update state. To generate a
@@ -71,7 +65,7 @@ extension Store {
71
65
///
72
66
/// - Parameter state: The state of the view.
73
67
/// - Returns: A store for previews.
74
- public static func preview< State> (
68
+ static func preview< State> (
75
69
state: State
76
70
) -> Store < StateAccessor < State > > where Model == StateAccessor < State > {
77
71
preview { context in
0 commit comments