MVCoconut / coconut.data

Observable Data Layer.
The Unlicense
20 stars 8 forks source link

Runtime null reference when transition called from constructor #73

Closed serjek closed 3 years ago

serjek commented 3 years ago
static function main() {
    var m = new TestModel({data: "false"});
}

class TestModel implements Model {
    @:external var data:String;
    @:constant var values:Faulty = new Faulty({someBool:someBool});
    @:computed var someBool:Bool = true;
}

class Faulty implements Model {
    @:external var someBool:Bool;
    @:observable var value:String = "none";
    @:transition function boom()
        return someBool ? {value:"a"} : {};

    public function new() {
        boom();
    }
}

TypeError: undefined is not an object (evaluating 'this1.getValue') when it tries to evaluate external param in Faulty model

serjek commented 3 years ago

I could not reduce this example even further as removing unused params makes this bug go away for some reason.

serjek commented 3 years ago

worth noting, haxe.Timer.delay(boom,0) this fixes the problem.

serjek commented 3 years ago

it appears order of variables matters.In TestModel: if computed declared before constant then issue is gone.