Thoughts on Hashable Actions #8
-
Currently my practice for cancellable identifiers is using the hashValue of my actions. Hashable conformance is not a necessity for Actions but I find it can be convenient and auto synthesized conformance takes place frequently. Does this solution lack some functionality? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello! From my experience, it's very difficult to have a root Aside from this, you will have as many identifiers as cases in your action. This usually works fine, especially for "naked" cases without associated values, as you probably have more cases than you need. You can imagine adding new cases to only play the role of identifiers, but I clearly don't recommend it. One advantage over the "standard" way This library also provides So if you manage to have Having So yes it can work, especially with raw cases and if the domain helps, and you immediately enjoy their benefits, but you may have to pay the price later, implementing things that will need to bear some logic (and thus, brainpower), whereas identifier declaration is always straightforward. I hope this answer your question. |
Beta Was this translation helpful? Give feedback.
Hello!
From my experience, it's very difficult to have a root
Action
that can conform automatically toHashable
. As soon as some associated value isn't hashable, you need to implement hashable conformance for the whole type hosting the action. And you don't need to go far to encounter non-hashable types likeCGSize
orAnimation
. Of course, you can conform types you don't own to protocols you don't own, but this is generally considered a bad practice, and you see immediately how this can be tricky in some semi-opaque cases likeAnimation
.Aside from this, you will have as many identifiers as cases in your action. This usually works fine, especially for "naked" cases without associated valu…