Git Product home page Git Product logo

ebus-rs's Introduction


ebus

ebus is a simple Eventbus implementation written in Rust.

Report Bug · Request Feature

About The Project

This is a small Eventbus implementation that can be used to asynchronously transmit data to subscribers of a EventBus instance.

Usage

  • To build the lib run: cargo build --release
  • To run the example run: cargo run --example basic-implementation

Basic Example

use ebus::{async_subscriber, EventBus, Subscriber};

#[derive(Default)]
pub struct ExampleSubscriber;

#[async_subscriber]
impl Subscriber for ExampleSubscriber {
    type Input = String;

    async fn on_event_publish(&mut self, event: &Self::Input) {
        println!("Received Data: {:#?}", event);
    }
}

#[tokio::main]
async fn main() {
    // Create a new event bus
    let mut event_bus = EventBus::default();

    // Create a new subscriber and subscribe it to the event bus
    let subscriber = ExampleSubscriber::default();
    event_bus.subscribe(subscriber);

    // Create an event and queue it for processing
    let event_data = "Hello World!".to_owned();
    event_bus.queue_and_process(event_data).await;
}

Roadmap

See the open issues for a full list of proposed features (and known issues).

Contributing

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feat(amazing)/amazing-feature)
  3. Commit your Changes (git commit -m 'feat(amazing): such progress')
  4. Push to the Branch (git push origin feat(amazing)/amazing-feature)
  5. Open a Pull Request

License

Distributed under the MIT or Apache 2 License. See LICENSE-MIT or LICENSE-APACHE for more information.

ebus-rs's People

Stargazers

 avatar  avatar

Watchers

 avatar

ebus-rs's Issues

remove Event struct

Event Struct doesn't provide any benefit or useful functionality at the moment

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.