firespine

Crates.iofirespine
lib.rsfirespine
version0.1.3
sourcesrc
created_at2022-05-25 19:05:41.9814
updated_at2022-10-31 14:04:03.665027
descriptionA relatively simple framework-as-a-library for application-state, -routing and event-handling.
homepagehttps://github.com/Longor1996/firespine
repositoryhttps://github.com/Longor1996/firespine
max_upload_size
id593707
size44,116
Lars Longor K (Longor1996)

documentation

README

Firespine

A relatively simple framework-as-a-library for application-state, -routing and event-handling.

Usage

use firespine::{Backbone, NodeHandler};

#[derive(Debug)]
struct MyNodeHandler;
impl NodeHandler for MyNodeHandler {
    // Override handler methods as needed!
    
    // For example, to receive events:
    fn handle_event<'e>(
        &'e mut self,
        event: &'e mut EventWrapper,
        context: &'e mut NodeContext,
    ) {
        if let Some(my_event) = event.downcast_ref::<MyEvent>() {
            // Handle the event! :D
        }
    }
}

#[derive(Debug)]
struct MyEvent;
impl Event for MyEvent {}

fn main() {
    let mut backbone = Backbone::from(MyNodeHandler);
    
    // 'navigate' to a path in the backbone.
    backbone.navigate("/local/world-3/play");
    
    loop {
        // Regularly call `update` in your mainloop...
        backbone.update().expect("backbone error");
        
        /// ...and fire away as you wish!
        backbone.get_context().process_event(&mut MyEvent);
    }
}
Commit count: 39

cargo fmt