0๐
โ
You cant reference a parameter and expect it to be changed outside, but you can pass a reference to an object that can change something outside.
var $this = this;
this.counter({
get() { return $this.userMinerals },
set(val) { $this.userMinerals = val }
});
and then use in the counter like this
counter(typeOfCredits) {
setInterval(() => {
typeOfCredits.set(typeOfCredits.get() + this.miners);
if(this.checkLimit(this.userMinerals, this.mineralsLimit)) {
typeOfCredits.set(this.mineralsLimit);
}
}, 100);
},
๐คEvaldo Bratti
0๐
typeOfCredits
is a parameter to the function. Parameters are passed by value. Modifying it is like modifying a local variable.
๐คRoy J
Source:stackexchange.com