Event pattern & event properties framework

Overview

Android CI

Renetik Android - Event & Property

https://github.com/renetik/renetik-android-event

Documentation

Framework to enjoy, improve and speed up your application development while writing readable code. Used as library in many projects and improving it while developing new projects. I am open for Hire or investment in my mobile app music production & perfromance project Renetik Instruments www.renetik.com.

Installation

allprojects {
    repositories {
        // For master-SNAPSHOT
        maven { url 'https://github.com/renetik/maven-snapshot/raw/master/repository' }
        // For release builds
        maven { url 'https://github.com/renetik/maven/raw/master/repository' }
    }
}
dependencies {
    implementation 'com.renetik.library:renetik-android-event:$renetik-android-version'
}

Examples

/**
 * Simple event use cases
 */
class EventTest {
    @Test
    fun testListen() {
        val event = event()
        var count = 0
        event.listen { count += 1 }
        event.fire()
        event.fire()
        assertEquals(count, 2)
    }

    @Test
    fun testArgListen() {
        val event = event()
        var count = 0
        event.listen { count += it }
        event.fire(2)
        event.fire(3)
        assertEquals(count, 5)
    }

    @Test
    fun testListenOnce() {
        val event = event()
        var count = 0
        event.listenOnce { count += 1 }
        event.fire()
        event.fire()
        assertEquals(count, 1)
    }

    @Test
    fun testArgListenOnce() {
        val event = event()
        var count = 0
        event.listenOnce { count += 1 }
        event.fire()
        event.fire()
        assertEquals(count, 1)
    }

    @Test
    fun testEventCancel() {
        val event = event()
        var count = 0
        event.listen { registration, _ ->
            count += 1
            if (count == 2) registration.cancel()
        }
        event.fire()
        event.fire()
        event.fire()
        assertEquals(count, 2)
    }

    @Test
    fun testStringEventCancel() {
        val event = event()
        var value: String? = null
        event.listen { registration, newValue ->
            if (newValue == "second") registration.cancel()
            value = newValue
        }
        event.fire("first")
        assertEquals("first", value)
        event.fire("second")
        assertEquals("second", value)
        event.fire("third")
        assertEquals("second", value)
    }

    @Test
    fun testEventPause() {
        val event = event()
        var count = 0
        val registration = event.listen { count += 1 }
        registration.pause { event.fire() }
        assertEquals(count, 0)
        event.fire()
        assertEquals(count, 1)
    }
}

count += value if (count > 2) registration.cancel() } property.value = 1 property.value = 2 property.value = 3 assertEquals(count, 3) } @Test fun testEventPause() { var count = 0 val property = property(0) val registration = property.onChange { count += it } registration.pause { property.value = 1 } assertEquals(count, 0) property.value = 2 assertEquals(count, 2) } }">
/**
 * Simple event property use cases
 */
class EventPropertyTest {

    @Test
    fun testOnChange() {
        val property = property("initial")
        var count = 0
        property.onChange { count += 1 }
        property.value = "second"
        property.value = "third"
        assertEquals(count, 2)
        assertEquals("third", property.value)
    }

    @Test
    fun testOnApply() {
        var count = 0
        val property = property("initial") { count += 1 }.apply()
        property.value = "second"
        property.value = "third"
        assertEquals(count, 3)
        assertEquals("third", property.value)
    }

    @Test
    fun testArgListen() {
        var count = 0
        val property = property(0) { count += 1 }
        property.value += 2
        property.value += 3
        assertEquals(5, property.value)
        assertEquals(2, count)
    }

    @Test
    fun testEquals() {
        var count = 0
        val property = property("") { count += 1 }
        property.value = "second"
        property.value = "second"
        assertEquals(count, 1)
        assertEquals("second", property.value)
    }

    @Test
    fun testOnChangeOnce() {
        var count = 0
        val property = property("")
        property.onChangeOnce { count += 1 }
        property.value = "second"
        property.value = "third"
        assertEquals(count, 1)
        assertEquals("third", property.value)
    }

    @Test
    fun testEventCancel() {
        var count = 0
        val property = property(0)
        property.onChange { registration, value ->
            count += value
            if (count > 2) registration.cancel()
        }
        property.value = 1
        property.value = 2
        property.value = 3
        assertEquals(count, 3)
    }

    @Test
    fun testEventPause() {
        var count = 0
        val property = property(0)
        val registration = property.onChange { count += it }
        registration.pause { property.value = 1 }
        assertEquals(count, 0)
        property.value = 2
        assertEquals(count, 2)
    }
}
/**
 * Event unregister after owner nulled
 */
class EventOwnerEventTest {
    @Test
    fun testUnregisteredAfterNilled() {
        val owner = CSEventOwnerHasDestroyBase()
        val event = event()
        var count = 0
        owner.register(event.listen { count += 1 })
        event.fire()
        event.fire()
        assertEquals(count, 2)
        owner.destroy()
        event.fire()
        assertEquals(count, 2)
    }
}
/**
 * Event property unregister after owner nulled
 */
class EventOwnerPropertyTest {
    class SomeClass(argument: SomeClass? = null) : CSEventOwnerHasDestroyBase(argument) {
        val string = property("initial value")

        init {
            register(argument?.string?.onChange { string.value = it })
        }
    }

    @Test
    fun testUnregisteredAfterNilled() {
        val instance1 = SomeClass()
        val instance2 = SomeClass(instance1)
        val instance3 = SomeClass(instance2)
        assertEquals(instance3.string.value, "initial value")
        instance1.string.value = "first value"
        assertEquals(instance3.string.value, "first value")
        instance2.destroy()
        instance1.string.value = "second value"
        assertEquals(instance3.string.value, "first value")
    }
}
You might also like...
Project allowing to query products (languages, libraries, databases, etc) by their properties.

Products app This project allow to search products (mostly software products for now such as languages, libraries etc) based on their properties. For

🚀🌆🏙 Display differences or animate progress between 2 images or Composables with overlay and customization options, zoom, pan gestures, and progress to observe properties for animating before-after progress

Compose Before-After Composables to display Images, or Composables as before and after composables to display differences or animate progress between

This prototype app provides a list of events to be held under an organization (school, college, club, etc.) and the users can manually set event reminders at their scheduled time so that they do not miss an event.

E-CELL NITS Sample App This prototype app provides a list of events to be held under E-Cell NIT Silchar (for example, Srijan 2.0) and the users can ma

Nucleus is an Android library, which utilizes the Model-View-Presenter pattern to properly connect background tasks with visual parts of an application.

Nucleus Deprecation notice Nucleus is not under develpment anymore. It turns out that Redux architecture scales way better than MVP/MVI/MVVM/MVxxx and

A Simple Todo app design in Flutter to keep track of your task on daily basis. Its build on BLoC Pattern. You can add a project, labels, and due-date to your task also you can sort your task on the basis of project, label, and dates
A Simple Todo app design in Flutter to keep track of your task on daily basis. Its build on BLoC Pattern. You can add a project, labels, and due-date to your task also you can sort your task on the basis of project, label, and dates

WhatTodo Life can feel overwhelming. But it doesn’t have to. A Simple To-do app design in flutter to keep track of your task on daily basis. You can a

With MVVM Architecture pattern using Android Architecture Components This is a sample app demonstrating Youtube player animation using constraint layout
With MVVM Architecture pattern using Android Architecture Components This is a sample app demonstrating Youtube player animation using constraint layout

Youtube UI/UX Animation This is a sample app demonstrating Youtube UX/UI animation using ConstraintLayout.It implements the Keyframe Animation feature

Navigation pattern like in Google News Stand app with transitions

Google-NewsStand-Animation-Android Navigation pattern like in Google News Stand app with transitions Getting Started In your build.gradle dependencies

Annotation Processing Library. Generates proxy class on top of interface/abstract class, that allows to intercept calls. Also known as a design pattern: proxy, delegate, interceptor.
Annotation Processing Library. Generates proxy class on top of interface/abstract class, that allows to intercept calls. Also known as a design pattern: proxy, delegate, interceptor.

1. AutoProxy Annotation Processing Library. Generates proxy class on top of interface/abstract class, that allows to intercept calls. Also known as a

Nucleus is an Android library, which utilizes the Model-View-Presenter pattern to properly connect background tasks with visual parts of an application.

Nucleus Deprecation notice Nucleus is not under develpment anymore. It turns out that Redux architecture scales way better than MVP/MVI/MVVM/MVxxx and

 android custom listview,with interaction pattern load more and pull to refresh to load data  dinamically
android custom listview,with interaction pattern load more and pull to refresh to load data dinamically

The first thing that i have to say is render thanks to johannilsson because all the part of pull to refresh listview is based in the code of his repos

Android ListView that implements the QuickReturn UI pattern. Written from scratch with focus on performance.
Android ListView that implements the QuickReturn UI pattern. Written from scratch with focus on performance.

QuickReturn Android ListView that implements the QuickReturn UI pattern. Written from scratch with focus on performance. Demo Usage In your build.grad

ActionsContentView is an standalone library implements actions/content swiping view (AKA Side Navigation UI Pattern, AKA Facebook side menu).  The library doesn't use any specific code introduced in new Android SDK versions. This allows develop an application with an action/content swiping view for every version of Android from 2.2 and up. Implementation of
Implementation of "Side Navigation" or "Fly-in app menu" pattern for Android (based on Google+ app)

Android SideNavigation Library Implementation of "Side Navigation" or "Fly-in app menu" pattern for Android (based on Google+ app). Description The Go

(Deprecated) A custom view component that mimics the new Material Design Bottom Navigation pattern.
(Deprecated) A custom view component that mimics the new Material Design Bottom Navigation pattern.

BottomBar (Deprecated) I don't have time to maintain this anymore. I basically wrote the whole library in a rush, without tests, while being a serious

A fork of our clean architecture boilerplate using the Model-View-Intent pattern

Android Clean Architecture MVI Boilerplate Note: This is a fork of our original Clean Architecture Boilerplate, except in this repo we have switched o

Library project with a custom view that implements the Float Label pattern

AndroidFloatLabel This repository contains an Android library project for Android 4.0+ with a custom view that implements the Float Label pattern (htt

A sample app showing how to build an app using the MVI architecture pattern.
A sample app showing how to build an app using the MVI architecture pattern.

MVI Example This application was streamed live on Twitch to demonstrate how to build an application using MVI. You can find the VOD here for now: http

A sample project in Kotlin to demonstrate AndroidX, MVVM, Coroutines, Hilt, Room, Data Binding, View Binding, Retrofit, Moshi, Leak Canary and Repository pattern.

This repository contains a sample project in Kotlin to demonstrate AndroidX, MVVM, Coroutines, Hilt, Room, Data Binding, View Binding, Retrofit, Moshi, Leak Canary and Repository pattern

typedmap is an implementation of heterogeneous type-safe map pattern in Kotlin

Typedmap typedmap is an implementation of heterogeneous type-safe map pattern in Kotlin. It is a data structure similar to a regular map, but with two

Releases(1.9.38)
Owner
Renetik
Engineering and Design. Mind that I can live in, like to build a product, design it & improve, solve technical and other challenges.
Renetik
Event bus for Android and Java that simplifies communication between Activities, Fragments, Threads, Services, etc. Less code, better quality.

EventBus EventBus is a publish/subscribe event bus for Android and Java. EventBus... simplifies the communication between components decouples event s

Markus Junginger 24.2k Jan 7, 2023
An enhanced Guava-based event bus with emphasis on Android support.

Otto - An event bus by Square An enhanced Guava-based event bus with emphasis on Android support. Otto is an event bus designed to decouple different

Square 5.2k Jan 9, 2023
Powerful event-bus optimized for high throughput in multi-threaded applications. Features: Sync and Async event publication, weak/strong references, event filtering, annotation driven

MBassador MBassador is a light-weight, high-performance event bus implementing the publish subscribe pattern. It is designed for ease of use and aims

Benjamin Diedrichsen 931 Dec 23, 2022
🕹️ See how the properties of Android's "shape" affect the Drawable's appearance, intuitively.

GradientDrawableTuner English | 中文 Get confusing about the drawable in Android? Try playing with GradientDrawableTuner! With the GradientDrawableTuner

Hong Duan 344 Nov 29, 2022
A Java/Kotlin library for Android platform, to manage bean's persistence in SQLite, SharedPreferences, JSON, XML, Properties, Yaml, CBOR.

Thanks to JetBrains for support Kripton Persistence Library project! Kripton Persistence Library Kripton is a java library, for Android platform, that

xcesco 117 Nov 11, 2022
Easy lightweight SharedPreferences library for Android in Kotlin using delegated properties

Easy lightweight SharedPreferences library for Android in Kotlin using delegated properties Idea Delegated properties in Kotlin allow you to execute a

null 25 Dec 27, 2022
A set of extension properties on Int, Long, Double, and Duration, that makes it easier to work with Kotlin Duration

Kotlin Duration Extensions Gradle Groovy repositories { mavenCentral() } implementation 'com.eygraber:kotlin-duration-extensions:1.0.1' Kotlin rep

Eliezer Graber 8 Nov 8, 2022
A small plugin which loads an additional properties file for secret values.

Gradle Secrets Plugin A small plugin which loads an additional properties file for secret values. Why Using this plugin, you can have an additional fi

null 7 Dec 25, 2022
This repository demonstrates how Kotlin can simplify Spring Boot configuration properties file mapping

Kotlin spring-boot nested config props This repository demonstrates how Kotlin can simplify Spring Boot configuration properties file mapping @Constru

Maksim Kostromin 1 Oct 11, 2021
Dynamic Badge with customizable features as max number before displaying with +, color, shadow, border, corner radius, font properties and more written with Jetpack Compose

✏️?? Dynamic Badge with customizable features as max number before displaying with +, color, shadow, border, corner radius, font properties and more written with Jetpack Compose. Displays numbers either in circle or rounded rectangle shape based on badge count and selected threshold to transform from circle to rounded rectangle.

Smart Tool Factory 4 Jul 27, 2022