tc39 / proposal-signals

A proposal to add signals to JavaScript.
MIT License
3.29k stars 57 forks source link

Well-defined ordering for operations #76

Open littledan opened 5 months ago

littledan commented 5 months ago

In order to guarantee common behavior across implementations, it would be good to define common orders for how certain operations work, and to test these. Some examples:

While working on defining these details, attention should be paid to whether we are placing a heavy burden on implementations (eg if the requirements lead to less efficient data structures)

littledan commented 5 months ago

@shaylew and I discussed this issue. There are sort of two coherent ways through:

What doesn't feel really coherent is the current semantics, where removing things from sets brings something back from the end. This is efficient to implement but feels a little weird.

shaylew commented 5 months ago

When multiple errored computed signals are data dependencies of another computed, and this results in an AggregateError, the order of the errors

Are we doing AggregateError there? I thought we'd just rerun the computed and let whichever one it reads first throw.

We do need AggregateErrors for when multiple watcher callbacks throw during one set operation, and maybe also for watched/unwatched (still need to figure out where those end up IIRC); presumably these should be in the order the throwing userland callbacks ran.