Right... Because you're not scoping correctly. Within a function, even a IIFE, the 'this' pointer is different from the enclosing scope. Example:
class TestClass {
someFunc() {
// 'this' references an instance of TestClass, so this will work:
this.otherFunc();
(function() {
// 'this' references 'window' and this will not work
this.otherFunc();
})();
((function() {
// 'this' references the same instance of TestClass as the enclosing scope
// due to the bind call, so this will work:
this.otherFunc();
}).bind(this))();
(() => {
// 'this' references the same instance of TestClass as the enclosing scope
// due to the 'fat-arrow' syntax, so this will work:
this.otherFunc();
})();
}
otherFunc() {
console.log('It works!');
}
}
I suggest you use the fat-arrow syntax:
this.delay(() => {this.createNewDataSource(true);}, 1000);