Is function.bind gone?
kabexef
Posts: 75
I try to connect a bound function to a signal to get my old context back. Unfortunately i get the error 'TypeError: Result of expression 'fctn.bind' [undefined] is not a function.'.
var bbb = { "txt": "BBB-Text", "p1": "BBB-P1", "go": function(localThis) { print("Function Code (this): Text = " + this.txt + "; p1 = " + this.p1); print("Function Code (bbb): Text = " + bbb.txt + "; p1 = " + bbb.p1); } } print("*** BBB GO ***"); bbb.go(); print("*** FCTN GO ***"); var fctn = bbb.go; fctn(); function anotherFunction() { print("anotherFunction"); } var timer = new DzTimer(); timer.timeout.connect(anotherFunction); timer.timeout.connect(bbb.go); timer.timeout.connect(fctn); timer.timeout.connect(fctn.bind(bbb)); // TypeError: Result of expression 'fctn.bind' [undefined] is not a function. print("*** TIMER START ***"); timer.singleShot = true; timer.start(100); // sleep... // keep script alive while timer is running
Ok, the workaround (directly referencing the defining var) will work ... but is not what i wanted.
Post edited by kabexef on