Skip to content

Instantly share code, notes, and snippets.

View arstagaev's full-sized avatar
🌌
Mad respect for the makers of things

Arsen Tagaev arstagaev

🌌
Mad respect for the makers of things
View GitHub Profile
@arstagaev
arstagaev / simple_observer.kt
Created May 7, 2022 10:01 — forked from wesleybliss/simple_observer.kt
Simple Kotlin Observer Pattern
interface Observer<T> {
fun onChange(newValue: T?)
}
class Observable<T>(initialValue: T? = null) {
// List ov observers watching this value for changes
private val observers = mutableListOf<Observer<T>>()
// The real value of this observer