File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,8 @@ public struct Random<Value>: DynamicProperty {
77 /// A wrapper of the underlying random number generator that can override
88 /// the seed value used.
99 public struct Wrapper {
10- /// A value used by the property wrapper to generate the value.
10+ /// A value used by the property wrapper to generate the value or `nil`
11+ /// if a per-`View` value will be used.
1112 ///
1213 /// Assign a value derived from your model object to this property to
1314 /// produce repetable random values across view instances.
@@ -29,7 +30,9 @@ public struct Random<Value>: DynamicProperty {
2930 /// }
3031 /// }
3132 /// ```
32- public var seed : Int
33+ ///
34+ /// Default is `nil`.
35+ public var seed : Int ?
3336 }
3437
3538 enum Source {
@@ -97,11 +100,11 @@ public struct Random<Value>: DynamicProperty {
97100 case . fixed( let int) :
98101 . init( seed: int)
99102 case . namespace:
100- . init( seed: namespace . hashValue )
103+ . init( seed: nil )
101104 }
102105 }
103106 set {
104- source = . fixed ( newValue. seed)
107+ source = newValue. seed. map ( Source . fixed ) ?? . namespace
105108 }
106109 }
107110}
You can’t perform that action at this time.
0 commit comments