haxetink / tink_state

Handle those pesky states.
The Unlicense
29 stars 13 forks source link

Expose the max iteration number #52

Closed kevinresol closed 4 years ago

back2dos commented 4 years ago

Fine by me. That said, Measurement based observables have relatively poor performance characteristics, so you may want to avoid them ;)

kevinresol commented 4 years ago

I dunno what is Measurement based observable tbh. But I am having issue with a observable that has a very deep and broad dependency in coconut.data

kevinresol commented 4 years ago

My code is something like this:

@:observable var list:List<...>;
@:computed var count:Int = list.count(v -> v.observableBool);

the list is of size ~100 and each of the observableBool depends on another 2-3 observables. and I got the error from AutoObservable (the error message is: no result after N attempts) rather than SimpleObservable

back2dos commented 4 years ago

Hmm. That's odd.

Basically, when recomputing, the logic goes something like this:

while (!valid) {
  valid = true;
  computation();
}

So if the computation invalidates the result, it is rerun. Ideally, computations have no side effects, and therefore do not invalidate anything. Sometimes, it's more practical to do that, but if it happens >100 in a single observable, something is weird, either in tink_state or in your code ^^

kevinresol commented 4 years ago

Is there a way to know what is being invalidated and causes the rerun? I don't think I have code that invalidate stuff during computation...

back2dos commented 4 years ago

Well, it's still a little crude, but you can compile with -D tink_state.debug, then subclass tink.state.debug.Logger to override triggered and then add that logger.