-
Notifications
You must be signed in to change notification settings - Fork 6
Description
This is a problem which troubled me for a while and I discovered it might potentially be a rather major issue.
When adding a mutation, it is necessary to declare ports. We declare a port as an argument, as things are set up currently, either as an IOPort or as a WritablePort. They are, then, handled differently in recordDeps: either as dependency or precedence to the mutation.
reactor-ts/src/core/reactor.ts
Lines 659 to 665 in f5c195f
| if (a instanceof IOPort) { | |
| this._dependencyGraph.addEdge( | |
| a, | |
| reaction as unknown as Reaction<Variable[]> | |
| ); | |
| sources.add(a); | |
| } else if (a instanceof MultiPort) { |
reactor-ts/src/core/reactor.ts
Lines 689 to 695 in f5c195f
| } else if (a instanceof WritablePort) { | |
| this._dependencyGraph.addEdge( | |
| reaction as unknown as Reaction<Variable[]>, | |
| a.getPort() | |
| ); | |
| effects.add(a.getPort()); | |
| } else if (a instanceof WritableMultiPort) { |
The issue is, they are able to be converted to one another inside of the mutation (by using this.getReactor().writable(port), or (port as unknown as WritablePort<number>).getPort()), and potentially create a causality loop. Unfortunately to do connection inside of a mutation, it appears that IOPort version is required, and if we want to connect AND write to a port then conversion is necessary (either pass in an WritablePort and convert to IOPort when connecting, or pass in an IOPort and convert to WritablePort).