You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi 👋
first of all, thanks for this awesome utility library, I am having great time using it.
However, there is one use case which I think could be optimized. I find myself in situations, where I need to get access to the underlying string constants behind my actions/unions.
This leads me to write unions like this, which gets very boilerplateful and verbose pretty fast.
constON='ON';constOFF='OFF';constState=unionized({[ON]: ofType<{}>(),[OFF]: ofType<{}>()})// do something later with tagconsole.log(ON)// 'ON'
In perfect world, .is, .match and .transform should be enough, but when interfacing with specific libraries the need to access union tags is unavoidable. This in turn requires the user to sacrifice brevity.
Proposal
Store Record<tags, tags> inside the Unionized object.
Usage example:
constState=unionized({ON: ofType<{}>(),OFF: ofType<{}>()})// do something later with tagconsole.log(State.tags.ON)// 'ON'
I will be 100% willing and happy to prepare a PR with that feature, just let me know if you are interested in it and would like to include such functionality into the codebase.
Cheers 😄
The text was updated successfully, but these errors were encountered:
Hi 👋
first of all, thanks for this awesome utility library, I am having great time using it.
However, there is one use case which I think could be optimized. I find myself in situations, where I need to get access to the underlying string constants behind my actions/unions.
This leads me to write unions like this, which gets very boilerplateful and verbose pretty fast.
In perfect world,
.is
,.match
and.transform
should be enough, but when interfacing with specific libraries the need to access union tags is unavoidable. This in turn requires the user to sacrifice brevity.Proposal
Store Record<tags, tags> inside the
Unionized
object.Usage example:
I will be 100% willing and happy to prepare a PR with that feature, just let me know if you are interested in it and would like to include such functionality into the codebase.
Cheers 😄
The text was updated successfully, but these errors were encountered: