Git Product home page Git Product logo

kevent's Introduction

KEvent: A brand new communication library in Android & Kotlin (similar to Eventbus)

Jitpack License API Release_Channel

KEvent is an open-source library for kotlin using the publisher/subscriber pattern for loose coupling. KEvent enables central communication to decoupled classes with just a few lines of code - simplifying the code, removing dependencies and speeding up app development.

Benefits

  • Global observers that always alive
  • Is none class implementation(no need to use in a class body - unlike Eventbus)
  • Simplifies the communication between components
  • Using Kotlin high-order functions
  • Decouples event sender
  • Is fast like EventBus
  • Is smaller than EventBus
  • Typed Observers that only accept events with determined Type
  • Post to specific observer
  • Post to specific observer with sender class
  • Event validation: Only Serializable/Parcelable data will be transferring, Events that are smaller than specific size(bytes) can be transferring(Due to avoid memory leak and increase the performance and speed, by default there is no size limitation added)

Installation

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

implementation 'com.github.janbarari:kevent:v1.1.0'

Setup

//Register observer
KEvent.register<T>("ObserverID") { event ->
    //Notice: event type is T, the Only events with the type of T can be observed here
}
KEvent.registerWithSender<T, Sender>("ObserverID") { event ->
    //Notice: event type is T, the Only events with the type of T and posted from sender class can be observed here
}

//Unregister observer
KEvent.unregister("ObserverID")

//Post to all observers that can accept the type of T
KEvent.post(T)
//Post to an observer with the mentioned ID that can accept the type of T
KEvent.post(T, "ObserverID")
//Post to an observer with the mentioned ID and sender class that can accept the type of T
KEvent.postWithSender<Sender>(T, "ObserverID")

Sponsor

If you like and use it, please tap the Star(⭐️) button at the above.

This source code is free for all; hence, it's not profitable. You can make me happy by donating me :)

License

Copyright (C) 2020 Mehdi Janbarari
KEvent binaries and source code can be used according to the Apache License, Version 2.0.

kevent's People

Contributors

janbarari 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.