Skip to content

Commit

Permalink
adding comments to code
Browse files Browse the repository at this point in the history
  • Loading branch information
lvllvl committed Apr 12, 2023
1 parent bd61b6b commit 4153843
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion boa_examples/src/bin/jspromise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ Context, JsValue, js_string};

fn main() -> Result<(), Box<dyn Error>> {

// Create a simple job queue to run the promise executor.
let queue = &SimpleJobQueue::new();
// Create a new context with the job queue.
let context = &mut Context::builder().job_queue(queue).build()?;

// Create a new promise object from an executor function.
let promise = JsPromise::new(|resolvers, context| {
let result = js_string!("hello world").into();
resolvers.resolve.call(&JsValue::undefined(), &[result], context)?;
Ok(JsValue::undefined())
}, context)?;

// Run all the jobs in the queue.
context.run_jobs();

assert_eq!(promise.state()?, PromiseState::Fulfilled(js_string!("hello world").into()));
Expand Down

0 comments on commit 4153843

Please sign in to comment.