I currently have a method called isSpecialStatus()
which has a simple return function
return (this.getStatus() === 'Special')
getStatus is also a simple return function with some conditionals
if (someArray.includes('SECRET_VALUE') {
return 'Special';
} else if (someArray.includes('OTHER_VALUE') // logic that's not relevant to this question
Instead of having all these conditional statements (the actual logic in the conditionals checks more than just one value)- we are using asynchronous calls to the DB that holds a list of values for each condition. So we can do
this.getSpecialValueList().then(results => console.log(results) // output: 'SECRET_VALUE'
however my isSpecialStatus()
is used throughout the codebase and I need it to return a boolean true/false instead of a promise that resolves into a true/false. I've tried using async/await and using promise chaining but no matter what- including the promise in isSpecialStatus
results in the output being a promise, not a boolean.
I have looked at other SO posts and have seen people recommend using outside variables and setting them and calling isSpecialStatus
in my case from within getStatus()
and it should return normally- which is fine- but I don't really want to add any global variables to my code if I can avoid it and the current scope of these methods would require the variable to be global on the window object.
Are there any alternatives other than promisifying all my methods that use isSpecialStatus()
or using global variables?