Storing Errors in State #1574
-
I have a use case where it would be useful to store an Some details around the use case:
Has anyone else come up against this problem? If so, what was your solve and are you happy with it? Is this strategy of holding onto the error and having the view inspect it an anti-pattern? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I'll let Brandon and Stephen weigh in on their solution ( |
Beta Was this translation helpful? Give feedback.
-
Hey @rzulkoski! While it is maybe possible to hack struct UserFacingError: Equatable {
let title: String
let description: String
let color: Color
} I wouldn't use |
Beta Was this translation helpful? Give feedback.
Hey @rzulkoski! While it is maybe possible to hack
TaskResult
Error
amenities, I would recommend to define your own "UserFacingError
" plain old data type from which you would create values to store into the state when anError
is received. For example, something like:I wouldn't use
Error
s to directly model things on the UI's side.