Skip to content

Commit

Permalink
prepping for 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andrieshiemstra committed Jun 18, 2020
1 parent cc59e11 commit cd234a5
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 43 deletions.
97 changes: 55 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,58 @@ So a second goal is to make implementing a fast and efficient integration doable

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.

# Examples

Cargo.toml

```toml
[dependencies]
# latest tag
es_runtime = {git = "https://github.com/DRFos/es_runtime", tag = "0.4.0"}
# or just get the latest
# es_runtime = {git = "https://github.com/DRFos/es_runtime"}

```

my_app.rs

```rust

#[test]
fn example() {
// start a runtime

let rt: EsRuntime = EsRuntimeWrapper::builder()
// run the garbage collector every 5 secs
.gc_interval(Duration::from_secs(5))
.build();

// create an example object

rt.eval_sync("this.myObj = {a: 1, b: 2};", "test1.es")
.ok()
.unwrap();

// add a rust function which will run async and thus return a promise in script
// you can also run your function sync by using add_global_sync_function instead
let func = |args: Vec<EsValueFacade>| {
// do something here, and then return a value as a EsValueFacade
Ok(EsValueFacade::new_i32(1268))
};
rt.add_global_async_function("myFunc", func);

// we can then use the function in script
rt.eval_sync("let prom = myFunc(1, 2, 3);\
prom.then((res) => {console.log('myFunc resolved to %s', res);});",
"test1.es")
.ok()
.unwrap();

}
```

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)

## 0.1 Goals

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

## 0.4 goals

* [x] EsProxy
* [x] Simpler method invocation (remove invoke_rust_op)
* [x] EsProxy (easy to use proxy class using EsValueFacade instead of JSAPI)
* [x] Simpler method invocation (deprecate invoke_rust_op)
* [x] Fix inline docs

## 0.5 goals

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


# Other plans

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

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


# Examples

Cargo.toml

```toml
[dependencies]
# latest tag
es_runtime = {git = "https://github.com/DRFos/es_runtime", tag = "0.3.5"}
# or just get the latest
# es_runtime = {git = "https://github.com/DRFos/es_runtime"}

```

my_app.rs

```rust

#[test]
fn example() {
// start a runtime

let rt = EsRuntimeWrapper::builder()
// run the garbage collector every 5 secs
.gc_interval(Duration::from_secs(5))
.build();

// create an example object

rt.eval_sync("this.myObj = {a: 1, b: 2};", "test1.es")
.ok()
.unwrap();

}

```

For a basic getting started you should see the examples in the [DOCS](https://drfos.github.io/es_runtime/es_runtime/index.html#examples)

# A word on compiling

Currently, I have only compiled this on and for a 64 bit linux machine (I use openSUSE).
Expand Down
2 changes: 1 addition & 1 deletion src/esruntime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ pub mod tests {

fn init_test_runtime() -> Arc<EsRuntime> {
log::info!("test: init_test_runtime");
simple_logging::log_to_file("esruntimewrapper.log", LevelFilter::Trace)
simple_logging::log_to_file("esruntime.log", LevelFilter::Trace)
.ok()
.unwrap();

Expand Down

0 comments on commit cd234a5

Please sign in to comment.