JSFiddle - React, Tailwind, and code Playground
JavaScript
example = {
overview: undefined,
aSyncFunction: function (callback) {
setTimeout(function(){
this.overview = {first: [{aa: 123, bb:000}], second: [{aa: 456, bb:999}]};
if (callback) {
callback();
}
}, 1000);
return this;
},
otherFunction: function (data) {
var result = false;
this.aSyncFunction( function () {
var available = this.overview[data.name];
result = (_.find(available, function(obj) {
return obj.aa === 123;
})) ? true : false;
}.bind(this));
return result;
}
};
console.log(example.otherFunction({name: 'first'}));