Closed foxdonut closed 7 years ago
I am using union-type for Meiosis examples. Thank you @paldepind for union-type, it's a great fit!
This PR would avoid the need for boilerplate _
, for example: https://github.com/foxdonut/meiosis-examples/blob/master/examples/temperatures/date/receive.js#L19
@paldepind thank you for looking at my PR. Indeed in the example I showed, it is to perform a side effect. But that is not the only use case. I also have something like var modelUpdate = proposal.case({...});
and if modelUpdate
is defined, I'll do something with it. Like you said, when a case isn't handled, I just want modelUpdate
to be undefined.
Thanks!
I see. So you'll check if modelUpdate
is undefined
later in the code.
Merged and released :smile_cat: Thank you for the PR!
Thank you @paldepind , much appreciated!
With
Type.check = false
, avoid TypeError: Cannot read property 'apply' of undefined.After setting
Type.check = false
, we should be able to write a handler that handles some, but not all, cases, without needing a catchall_
. This saves us from having to write boilerplate_: function() { }
code in handlers.