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
Is your feature request related to a problem? Please describe.
Mirth lacks optional chaining as Rhino lacks it. It is an extremely useful feature that saves a lot of typing
Describe your use case
Currently to safely access sub props you must use the es5 way to access the sub prop to avoid throwing if a parent prop is undefined
var d = (a && a.b && a.b.c) || undefined
// or
var d
try {
d = a.b.c
} catch (ignore) {
}
Describe the solution you'd like
Add the following script as part of the default environment.
/**
* $t is an inline try/catch to take the place of optional chaining ie var d = $t(()=> a.b.c) is the same as var d = a?.b?.c
*/
function $t(cb) {
try {
return cb()
} catch (ignore) {
// do nothing
}
}
This would enable the following
var d = $t(()=> a.b.c)
// or
var d = $t(()=> a.b.c) || 'default value'
It also enables other use cases beyond what standard optional chaining allows ie running unsafe code in a compact way.
var result = $t(() => someInstance.unsafeFunction())
if (result) {
// do something
}
Describe alternatives you've considered
It's quite easy to add a global code template to add $t in but it has been so useful and would be very simple for the Connect team to add I believe it should be a core method in Connect.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Mirth lacks optional chaining as Rhino lacks it. It is an extremely useful feature that saves a lot of typing
Describe your use case
Currently to safely access sub props you must use the es5 way to access the sub prop to avoid throwing if a parent prop is undefined
Describe the solution you'd like
Add the following script as part of the default environment.
This would enable the following
It also enables other use cases beyond what standard optional chaining allows ie running unsafe code in a compact way.
Describe alternatives you've considered
It's quite easy to add a global code template to add $t in but it has been so useful and would be very simple for the Connect team to add I believe it should be a core method in Connect.
The text was updated successfully, but these errors were encountered: