Skip to content

Commit cd234a5

Browse files
prepping for 0.4.0
1 parent cc59e11 commit cd234a5

2 files changed

Lines changed: 56 additions & 43 deletions

File tree

README.md

Lines changed: 55 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,58 @@ So a second goal is to make implementing a fast and efficient integration doable
2929

3030
The reason I chose SpiderMonkey as the engine is that I've been dealing with less modern engines in my java projects and not being able to use the latest and greatest ECMA-script features becomes quite disappointing at times.
3131

32+
# Examples
33+
34+
Cargo.toml
35+
36+
```toml
37+
[dependencies]
38+
# latest tag
39+
es_runtime = {git = "https://github.com/DRFos/es_runtime", tag = "0.4.0"}
40+
# or just get the latest
41+
# es_runtime = {git = "https://github.com/DRFos/es_runtime"}
42+
43+
```
44+
45+
my_app.rs
46+
47+
```rust
48+
49+
#[test]
50+
fn example() {
51+
// start a runtime
52+
53+
let rt: EsRuntime = EsRuntimeWrapper::builder()
54+
// run the garbage collector every 5 secs
55+
.gc_interval(Duration::from_secs(5))
56+
.build();
57+
58+
// create an example object
59+
60+
rt.eval_sync("this.myObj = {a: 1, b: 2};", "test1.es")
61+
.ok()
62+
.unwrap();
63+
64+
// add a rust function which will run async and thus return a promise in script
65+
// you can also run your function sync by using add_global_sync_function instead
66+
let func = |args: Vec<EsValueFacade>| {
67+
// do something here, and then return a value as a EsValueFacade
68+
Ok(EsValueFacade::new_i32(1268))
69+
};
70+
rt.add_global_async_function("myFunc", func);
71+
72+
// we can then use the function in script
73+
rt.eval_sync("let prom = myFunc(1, 2, 3);\
74+
prom.then((res) => {console.log('myFunc resolved to %s', res);});",
75+
"test1.es")
76+
.ok()
77+
.unwrap();
78+
79+
}
80+
```
81+
82+
For a more detailed getting started you should see the examples in the [DOCS](https://drfos.github.io/es_runtime/es_runtime/index.html#examples)
83+
3284
## 0.1 Goals
3385

3486
* [x] Get a grip on when to use rooted values (Handle) and when to use Values (JSVal)
@@ -67,8 +119,9 @@ The reason I chose SpiderMonkey as the engine is that I've been dealing with les
67119

68120
## 0.4 goals
69121

70-
* [x] EsProxy
71-
* [x] Simpler method invocation (remove invoke_rust_op)
122+
* [x] EsProxy (easy to use proxy class using EsValueFacade instead of JSAPI)
123+
* [x] Simpler method invocation (deprecate invoke_rust_op)
124+
* [x] Fix inline docs
72125

73126
## 0.5 goals
74127

@@ -91,52 +144,12 @@ The reason I chose SpiderMonkey as the engine is that I've been dealing with les
91144
* [ ] WebAssembly support
92145
* [ ] Much more
93146

94-
95147
# Other plans
96148

97149
I'm also working on a more feature rich runtime with a commandline tool, and an application server based on this runtime.
98150

99151
These are in a very early testing stage and may become available later as a separate project.
100152

101-
102-
# Examples
103-
104-
Cargo.toml
105-
106-
```toml
107-
[dependencies]
108-
# latest tag
109-
es_runtime = {git = "https://github.com/DRFos/es_runtime", tag = "0.3.5"}
110-
# or just get the latest
111-
# es_runtime = {git = "https://github.com/DRFos/es_runtime"}
112-
113-
```
114-
115-
my_app.rs
116-
117-
```rust
118-
119-
#[test]
120-
fn example() {
121-
// start a runtime
122-
123-
let rt = EsRuntimeWrapper::builder()
124-
// run the garbage collector every 5 secs
125-
.gc_interval(Duration::from_secs(5))
126-
.build();
127-
128-
// create an example object
129-
130-
rt.eval_sync("this.myObj = {a: 1, b: 2};", "test1.es")
131-
.ok()
132-
.unwrap();
133-
134-
}
135-
136-
```
137-
138-
For a basic getting started you should see the examples in the [DOCS](https://drfos.github.io/es_runtime/es_runtime/index.html#examples)
139-
140153
# A word on compiling
141154

142155
Currently, I have only compiled this on and for a 64 bit linux machine (I use openSUSE).

src/esruntime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ pub mod tests {
261261

262262
fn init_test_runtime() -> Arc<EsRuntime> {
263263
log::info!("test: init_test_runtime");
264-
simple_logging::log_to_file("esruntimewrapper.log", LevelFilter::Trace)
264+
simple_logging::log_to_file("esruntime.log", LevelFilter::Trace)
265265
.ok()
266266
.unwrap();
267267

0 commit comments

Comments
 (0)