Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async auto-observable value not being updated properly when not bound (only on v1 branch) #79

Open
nadako opened this issue Nov 27, 2022 · 1 comment

Comments

@nadako
Copy link
Contributor

nadako commented Nov 27, 2022

The following code returns Loading on the second value access, unless we bind (and thus wake up and do the triggerAsync thing). Only happens on the v1 branch, master is fine:

import tink.core.Future;
import tink.state.Observable;

function main() {
	var o = Observable.auto(() -> new Future(trigger -> {
		return haxe.Timer.delay(() -> trigger(10), 500).stop;
	}));

	trace(o.value);

	haxe.Timer.delay(() -> {
		trace(o.value); // still Loading
	}, 1000);
}
@back2dos
Copy link
Member

That's a "feature": #60

I'm not 100% sure that I like it, but the basic idea is that if the async computation is expensive, then it gets suspended if nobody is interested.

In the above example, nobody is observing any changes. You happen to know that if you wait long enough, the computation should have finished, but that is not quite the rule.

That being said, I'm not very thrilled with the new behavior myself. But I'd be eager to learn more about things that approximate real world use cases, in the hopes of coming up with something that has the intended benefits of #60, without messing up expectations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants