Skip to content

Commit

Permalink
Update blog/2024-12-05-boa-release-020/index.mdx
Browse files Browse the repository at this point in the history
Co-authored-by: raskad <[email protected]>
  • Loading branch information
jasonwilliams and raskad authored Dec 4, 2024
1 parent afd9486 commit 6de06c6
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion blog/2024-12-05-boa-release-020/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,29 @@ Boa has added support for the [stage 3 proposal `Atomics.pause`](https://github.
### Getters and Setters in the js_class! macro

You can now add getters and setters to the `js_class!` macro. This allows you to define getters and setters on your JavaScript classes in Rust. This is a feature that has been requested by many users of Boa, and thanks to @hansl we now have it!
[Point to example]
```rust
#[derive(Clone, Default, Trace, Finalize, JsData)]
pub struct Game {
score: u32,
}

js_class! {
class Game {
property score {
get(this: JsClass<Game>) -> u32 {
this.borrow().score
}

set(this: JsClass<Game>, new_value: u32) {
this.borrow_mut().score = new_value;
}
}

constructor() {
Ok(Game::default())
}
}
}

### Implement your own native Errors

Expand Down

0 comments on commit 6de06c6

Please sign in to comment.