Chaosy
Tutorial Reviewer
- Joined
- Jun 9, 2011
- Messages
- 13,239
What I want to do is:
So I made some google searches and found something called promises which seems easy enough to use - I thought.
So I did the following:
and in the parent constructor:
However when I run the code, I get the error:
Uncaught (in promise) Typerror: Cannot set property tag of undefined
(in the constructor I use this.tag for a whole lot of stuff)
So my guess is that "this" gets broken for some reason, and I have no clue how to fix it.
I tried to add .bind but that gave a syntax error.
Code:
class x extends y {
constructor () {
super();
// do something depandant on super
}
}
So I made some google searches and found something called promises which seems easy enough to use - I thought.
So I did the following:
Code:
class x extends y {
test() {
//do something
}
constructor() {
super().then(function() {
this.test();
});
}
}
and in the parent constructor:
Code:
return new Promise(function()
{
//do stuff
});
Uncaught (in promise) Typerror: Cannot set property tag of undefined
(in the constructor I use this.tag for a whole lot of stuff)
So my guess is that "this" gets broken for some reason, and I have no clue how to fix it.
I tried to add .bind but that gave a syntax error.
Last edited: