-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Match multiple patterns simultaneously #11
Comments
Supporting a string key of While it's not ideal, this is what I do for handling multiple cases: // definition of LoadState and state omitted; they'd be the same as in your issue description
const unavailable = () => "unavailable";
console.log("State is ", state.match({
Unstarted: unavailable,
Error: unavailable,
_: () => "available",
})); For something small like "unavailable" it looks silly, but when the match handler in question is larger, it makes more sense. |
Seems reasonable albeit not very ergonomic. Thought about doing it this way, also. Thanks! |
@suchipi If I, or anyone else for that matter, would offer you a PR that makes this feature possible, would you accept it? |
Yes, provided it was of good quality and etc |
Reopening to better communicate that interest |
I don't know how much I like the suggested approach with You might need something like |
Hi!
Thanks for this useful package.
I was wondering whether it is possible to match multiple patterns simultaneously? Like so:
I'm assuming it's not possible since it requires changes to how TypeScript treats
Something | AnotherThing
syntax, but maybe I'm wrong.The text was updated successfully, but these errors were encountered: