Skip to content

Separate Front-end and Back-end #65

@MilkBlock

Description

@MilkBlock

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:

  1. Guest send Ranim DSL to Host
  2. Host interpret the DSL to Rabject
  3. when Rabject on Host is triggered (clicked dragged...) call Guest defined Function
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions