You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If constructor of FruitsProvider is kept as in the example,
the name of the season will never show up ("unknown yet"): public function new(season:Option<Season>) this = { season:season }
But it will work if either:
type is removed , public function new(season) this = { season:season }
constructor is removed (in that case, built as new FruitsProvider({season:"winter"})))
The text was updated successfully, but these errors were encountered:
After I posted this, I tried to remove the type in the constructor of one of my classes (been struggling for weeks, there were like 4 rewrites) and suddenly all the app works and updates magically!
The build macro for Model working around the constructor maybe has a bug?
(I hope it's a bug and not a type issue)
The problem here is that @:external consumes a coconut.data.Value which is essentially an Observable with a @:from macro cast that will wrap non-observable expressions in Observable.auto(() -> $expr).
If you remove the type hint, then season is inferred to Value<Option<Season>> (which is the correct type to use here).
Thus var prov1 = new FruitsProvider(world.season); compiles to var prov1 = new FruitsProvider(Observable.auto(() -> world.season));.
If you leave the type as it is, then you get var prov1 = new FruitsProvider(world.season); and that only passes the current value to the FruitsProvider and its constructor implementation will be generated with this = { season: Observable.auto(() -> season) } - observing a function argument does not cause updates.
Sorry for the trouble. The upcoming v1 will axe this footgun: #77
Weird thing here:
If constructor of FruitsProvider is kept as in the example,
the name of the season will never show up ("unknown yet"):
public function new(season:Option<Season>) this = { season:season }
But it will work if either:
public function new(season) this = { season:season }
new FruitsProvider({season:"winter"}))
)The text was updated successfully, but these errors were encountered: