Separate Front-end and Back-end.
Use Egglog and a suit of Predefined Ranim Egglog Type to separate Front-end and Back-end to support interactive mode.
The procedure is like:
- Guest send Ranim DSL to Host
- Host interpret the DSL to Rabject
- when Rabject on Host is triggered (clicked dragged...) call Guest defined Function
- Guest send incremental Ranim DSL to Host to update the rendered Rabject
And the situation can be more complex when touching persistence (undo some operation).
Luckily we can deal with it easily with egglog (similar to persistent database which minimize the memory occupation).
I wrote a proc-macro lib by which you can easily define a suit of Predefined Ranim Egglog Type by #[egglog_ty] attribute.
#[allow(unused)]
#[egglog_ty]
enum Fn {
Builtin {
function: BuiltinF,
},
WasmGuestExtern {
name: String,
},
}
Ref:
https://github.com/MilkBlock/egglog_wrap_test/blob/master/crates/egglog_wrapper/src/lib.rs
And you can simply call such generated function to generate egglog statemnt in String.
let p = Point::<Rx>::new_fixed_point(&Offset::new_d_vec2(1.0, 0.));
while the Rx type specifiy a Receiver (Host). It will automatically call user defined receive function.
All code that user need write is here.
fn main() {
let p1 = Point::<Rx>::new_fixed_point(&Offset::new_d_vec2(1.0, 0.));
let p2 = Point::new_fixed_point(&Offset::new_d_vec2(1.0, 2.));
let ps = Points::new(vec![&p1,&p2]);
Rx::singleton().to_dot(PathBuf::from("egraph"));
}
which also enable users to inspect the graph they generated.
https://github.com/MilkBlock/egglog_wrap_test/blob/master/src/main.rs
Separate Front-end and Back-end.
Use Egglog and a suit of Predefined Ranim Egglog Type to separate Front-end and Back-end to support interactive mode.
The procedure is like:
And the situation can be more complex when touching persistence (undo some operation).
Luckily we can deal with it easily with egglog (similar to persistent database which minimize the memory occupation).
I wrote a proc-macro lib by which you can easily define a suit of Predefined Ranim Egglog Type by #[egglog_ty] attribute.
Ref:
https://github.com/MilkBlock/egglog_wrap_test/blob/master/crates/egglog_wrapper/src/lib.rs
And you can simply call such generated function to generate egglog statemnt in String.
while the Rx type specifiy a Receiver (Host). It will automatically call user defined
receivefunction.All code that user need write is here.
which also enable users to inspect the graph they generated.
https://github.com/MilkBlock/egglog_wrap_test/blob/master/src/main.rs