Giter Club home page Giter Club logo

gunfire's Introduction

Project Gunfire

Project Gunfire is a lightweight event bus framework which is built in and for the Kotlin Programming Language.
This can be used to fire bullets with guns!

Requirements

  • Kotlin/JVM 1.1.1+ (including coroutines)
  • Java Runtime for Java 8

Dependencies

  • Kotlinx-Coroutines for Kotlin 1.1.1+
  • Kotlin std-jre8 1.1.1+

Recommended IDE: Intellij IDEA 2017.1

Getting Started

To create an EventBus for your project you have to choose your Gun:

  • Gun
    The generic Gun which executes on the calling thread
  • Sniper
    Extension of a simple Gun which synchronizes each bullet shot
  • Revolver
    Extension of a simple Gun which can fire up to 6 bullets at once
  • Uzi
    Fully automatic Gun which uses kotlin coroutines for each bullet shot

Every Gun implementation inherits from the Gun class and iterates over all registered targets.

Setup Target

import club.minnced.gunfire.core.Gun
import club.minnced.gunfire.core.impl.Sniper
import club.minnced.gunfire.core.target

val gun: Gun = Sniper()

fun main(args: Array<String>) {
    gun.target<Backfire> {
        it.error.printStackTrace()
    }
    gun.target<LogBullet> {
        println(it.message)
    }
}

Note: Here we register a target that will print every Throwable that is caught by the Gun!
Using the Backfire bullet specification!

Fire Gun

import club.minnced.gunfire.core.Gun
import club.minnced.gunfire.core.impl.Sniper
import club.minnced.gunfire.core.fire

class LogBullet(val message: String)

fun logMessage(message: String) {
    gun.fire {
        LogBullet(message)
    }
}

Note: Here we fire a LogBullet which holds a message for the targets!

Setup

JitPack Version: version

Gradle

respositories {
    jcenter()
    maven {
        name 'jitpack.io'
        url 'https://jitpack.io'
    }
    // ...
}

dependencies {
    compile 'org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.1'
    compile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.14'
    compile 'com.github.MinnDevelopment.Gunfire:core:master-SNAPSHOT'
    compile 'com.github.MinnDevelopment.Gunfire:commons:master-SNAPSHOT'
    // ...
}

Maven

<repository>
    <url>https://jitpack.io</url>
</repository>
<!-- 
Add other repositories for Kotlin 1.1.1 and Kotlinx-Coroutines
This may require jcenter as repository listing!
-->
<dependencies>
    <dependency>
        <groupid>com.github.MinnDevelopment.Gunfire</groupid>
        <artifactId>core</artifactId>
        <version>master-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupid>com.github.MinnDevelopment.Gunfire</groupid>
        <artifactId>commons</artifactId>
        <version>master-SNAPSHOT</version>
    </dependency>
</dependencies>

Examples

There is a Step-by-Step guide and an example which uses bullets to print messages to the console in the Examples Directories!

gunfire's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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