File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Sources/ComposableArchitecture/SwiftUI Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 205
205
206
206
extension BindableState : Decodable where Value: Decodable {
207
207
public init ( from decoder: Decoder ) throws {
208
- self . init ( wrappedValue: try Value ( from: decoder) )
208
+ do {
209
+ let container = try decoder. singleValueContainer ( )
210
+ self . init ( wrappedValue: try container. decode ( Value . self) )
211
+ } catch {
212
+ self . init ( wrappedValue: try Value ( from: decoder) )
213
+ }
209
214
}
210
215
}
211
216
212
217
extension BindableState : Encodable where Value: Encodable {
213
218
public func encode( to encoder: Encoder ) throws {
214
- try self . wrappedValue. encode ( to: encoder)
219
+ do {
220
+ var container = encoder. singleValueContainer ( )
221
+ try container. encode ( self . wrappedValue)
222
+ } catch {
223
+ try self . wrappedValue. encode ( to: encoder)
224
+ }
215
225
}
216
226
}
217
227
You can’t perform that action at this time.
0 commit comments