@@ -44,11 +44,11 @@ Other http frameworks provide a single thread of execution, and a global
44
44
environment object which is used to configure each request and response in turn.
45
45
46
46
With Pardon, we offer the same ergonomics of a "global object", but the behavior
47
- is stable across promises: only awaited " assignments" to the "global object" are
48
- seen .
47
+ is independent of the execution order: since only _ awaited _ assignments to the
48
+ global object count .
49
49
50
50
The base of this is a tracking system that understands
51
- "what happened" to reach a certain point.
51
+ _ what happened _ to reach a certain point, by way of a series of tracked values .
52
52
53
53
In a single threaded usage, ` track(value) ` looks like it pushes a value
54
54
onto a list and ` awaited() ` returns that list.
@@ -96,14 +96,16 @@ awaited(); // ['f', 'g']
96
96
```
97
97
98
98
Notice that ` awaited() ` above can return any combination of ` 'f' ` and/or ` 'g' `
99
- in any order : depending on the order they were awaited,... rather than
100
- the order the ` track ` calls were executed.
99
+ in different orders : depending purely on the order they were awaited,
100
+ rather than the order the ` track ` calls were actually run!
101
101
102
- This might feel a bit weird, but it is _ stable_ , as the ` awaited() ` result is
103
- based on the shape of the code, rather than the unstable order of execution.
102
+ This might feel a bit weird at first, but it is _ stable_ , as the composition/order of the ` awaited() `
103
+ values will be based only on the (stable) lexical shape of the code, rather than the
104
+ unstable order of execution.
104
105
105
- We use this to track assignments to a global environment value as
106
- well as tracking the requests that comprise a particular test.
106
+ In tests, we use this to track assignments to a global environment value.
107
+ We also track dependent requests that might be executed via script helpers to
108
+ surface dependent requests in ` favor ` .
107
109
108
110
## How this Tracks
109
111
@@ -158,18 +160,14 @@ executes synchronously as well, while
158
160
159
161
Like all non-trivial abstractions, this one leaks: Memory.
160
162
161
- Obviously, the values in the ` awaited() ` list are "referenced" by the
162
- promises that carry them, but that reference is implemented by a graph
163
- of the execution of all the promises.
164
-
165
- The graph _ is_ garbage-collected along with promises, as much as possible,
163
+ The awaited values _ are_ garbage-collected along with promises, as much as possible,
166
164
but we have two helpers to cut the graph for correctness and
167
165
better garbage collection, respectively.
168
166
169
- - ` shared(() => { ... }) ` cuts the graph into the execution of ` ... ` .
170
- - ` disconnected(() => { ... }) ` cuts the graph leaving the execution ` ... ` .
167
+ - ` shared(() => { ... }) ` drops awaited values going into the execution of ` ... ` .
168
+ - ` disconnected(() => { ... }) ` drops awaited values leaving the execution of ` ... ` .
171
169
172
- Both of these methods immediately execute their function and
170
+ Both of these methods asynchronosuly start executing their function and
173
171
return a promise for its result.
174
172
175
173
### Shared Execution
@@ -186,7 +184,7 @@ function getAuthToken() {
186
184
in this case the ` authTokenPromise` will inherit the tracked values
187
185
leading to the first call of ` fetchAuthToken ()` only. This introduces
188
186
a race condition as the tracked results of ` getAuthToken ()` would
189
- depend on who called it first. Additioanlly the ` fetchAuthToken ()` function
187
+ depend on who called it first. Additionally the ` fetchAuthToken ()` function
190
188
would have access to the ` awaited ()` values of its first caller.
191
189
192
190
To fix this, we use ` shared` to disconnect the execution graph leading into the call.
0 commit comments