skdb icon indicating copy to clipboard operation
skdb copied to clipboard

[skipruntime-ts] AsyncLazyCompute.call should be static

Open mbouaziz opened this issue 1 year ago • 0 comments

IIUC, because call is called outside the reactive world, it should not access reactive stuff. If needed, params can pass things (plain data) to call.

Fail 1: a simple solution would be to force call to be static, though it is not possible to force an interface member to be static in Typescript.

Fail 2: make AsyncLazyCompute an abstract class? Yes, but then call cannot use type parameters because they're instance-specific in Typescript.

Fail 3: use bind to make sure this cannot be used. Yes, but then you cannot access members that would be fine, it prevents creating abstract classes implementing AsyncLazyCompute unless the abstract members are static methods, but they cannot be generic...

Another solution: bind to a proxy of this that works fine for plain data but not members that contain reactive values? Not sure how efficient this would be if we have to deeply proxy all member accesses.

mbouaziz avatar Oct 02 '24 15:10 mbouaziz