Giter VIP home page Giter VIP logo

van's Introduction

van

类似git操作的eventbus

Apache 2 jdk-8+



特点

  • 非常轻量,代码简单,大小只有8k
  • git命令操作,api友好
  • 支持编程式和注解
  • 支持jdk8+

使用方式

Maven

<dependency>
    <groupId>io.github.kongweiguang</groupId>
    <artifactId>van</artifactId>
    <version>0.1</version>
</dependency>

Gradle

implementation 'io.github.kongweiguang:van:0.1'

Gradle-Kotlin

implementation("io.github.kongweiguang:van:0.1")

简单介绍

详情看test的例子

编程式

public class PushTopicTest {
    String topic = "topic.test1";

    @Test
    void test() throws Exception {
        //拉取消息
        hub().pull(topic, m -> {
            System.out.println(m.id());
            System.out.println(m.content());
        });

        //推送消息
        hub().push(topic, "content");
        hub().push(topic, "content", e -> System.out.println("callback 1 -> " + e));
        hub().push(Action.of(topic, "content"));
        hub().push(Action.of(topic, "content"), e -> System.out.println("callback 2 -> " + e));
    }
}

注解式

public class PushObjMethodTest {
    @Test
    void test1() throws Exception {
        //设置拉取消息的处理
        hub().pull(new MyHandler());

        //推送tipic为bala的消息
        hub().push(Action.of("bala", new User(1, "k", new String[]{"h"})), object -> System.out.println("object = " + object));

        //推送topic为bala1的消息
        hub().push("bala1", new User(1, "k", new String[]{"h"}), object -> System.out.println("object = " + object));

        //推送user类的topic
        hub().push(new User(1, "k", new String[]{"h"}), object -> System.out.println("object = " + object));

        Van.<User, String>hub().push(new User(1, "k", new String[]{"h"}), object -> System.out.println("object = " + object));

    }
}

van's People

Contributors

kongweiguang avatar

Stargazers

 avatar

Watchers

 avatar

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.