@@ -76,7 +76,7 @@ pub type FutureJob = Pin<Box<dyn Future<Output = NativeJob> + 'static>>;
76
76
77
77
With this definition, it was pretty much impossible to capture the ` Context `
78
78
inside the ` Future ` , and functions that needed to interweave engine operations
79
- with awaiting ` Future ` s would have to be split into multiple parts:
79
+ with awaiting ` Future ` s needed to be split into multiple parts:
80
80
81
81
``` rust
82
82
let fetch = async move {
@@ -143,7 +143,7 @@ a `Future`.
143
143
144
144
After introducing the new job type, changes had to be made on
145
145
[ ` JobQueue ` ] ( https://docs.rs/boa_engine/0.20.0/boa_engine/job/trait.JobQueue.html )
146
- to better support new job types. Thus, ` JobQueue ` was revamped and renamed to be the
146
+ to better support new types of jobs . Thus, ` JobQueue ` was revamped and renamed to be the
147
147
new ` JobExecutor ` :
148
148
149
149
``` rust
@@ -283,18 +283,22 @@ finish_load: Box<dyn FnOnce(JsResult<Module>, &mut Context)>,
283
283
```
284
284
285
285
Unfortunately,
286
- this API has downsides: it is still possible to forget to call ` finish_load ` ,
287
- which is still safe but prone to bugs. It is also really painful to work with,
288
- because you cannot capture the ` Context ` to further process the module after
289
- loading it ... Sounds familiar? ** This is exactly [ the code snippet we talked about before!] ( #async-apis-enhancements ) **
286
+ this API has downsides: it is possible to forget to call ` finish_load ` ,
287
+ which is safer than a dangling ` *const() ` pointer, but still prone to bugs.
288
+ It is also really painful to work with, because you cannot capture the ` Context `
289
+ to further process the module after loading it ... Sounds familiar?
290
+ ** [ The async code snippet we showed before] ( #async-apis-enhancements ) has this exact problem!**
291
+ And that snippet is directly taken from [ one of our ` ModuleLoader ` implementation examples] [ mod-loader ] .
292
+
293
+ [ mod-loader ] : https://github.com/boa-dev/boa/blob/b345775138f56401bd627b1f36daadfc5bf75772/examples/src/bin/module_fetch.rs#L38
290
294
291
295
Fast forward a couple of years and we're now changing big parts of ` JobExecutor ` :
292
296
adding new job types, tinkering with ` JobExecutor ` , changing API signatures, etc.
293
297
Then, while looking at the definition of ` ModuleLoader ` , we thought...
294
298
295
299
> Huh, can't we make ` load_imported_module ` async now?
296
300
297
- And that's exactly what we did! Behold, the new ` ModuleLoader ` !
301
+ And that's exactly what we did. Behold, the new ` ModuleLoader ` !
298
302
299
303
``` rust
300
304
pub trait ModuleLoader : Any {
0 commit comments