All Projects → UrbanCompass → Snail-Kotlin

UrbanCompass / Snail-Kotlin

Licence: other
An observables framework for Kotlin

Programming Languages

kotlin
9241 projects
shell
77523 projects

Projects that are alternatives of or similar to Snail-Kotlin

Callbag Basics
👜 Tiny and fast reactive/iterable programming library
Stars: ✭ 1,619 (+3665.12%)
Mutual labels:  observables
observable-profiler
Tracks new & disposed Observable subscriptions
Stars: ✭ 41 (-4.65%)
Mutual labels:  observables
callbag-subscribe
A callbag sink (listener) that connects an Observer a-la RxJS. 👜
Stars: ✭ 17 (-60.47%)
Mutual labels:  observables
Snail
An observables framework for Swift
Stars: ✭ 163 (+279.07%)
Mutual labels:  observables
Rxjs Websockets
A very flexible and simple websocket library for rxjs
Stars: ✭ 248 (+476.74%)
Mutual labels:  observables
ng-effects
Reactivity system for Angular. https://ngfx.io
Stars: ✭ 46 (+6.98%)
Mutual labels:  observables
Rxphp
Reactive extensions for PHP
Stars: ✭ 1,580 (+3574.42%)
Mutual labels:  observables
wise-river
Object streaming the way it should be.
Stars: ✭ 33 (-23.26%)
Mutual labels:  observables
swift-observables-example
Observable Pattern implementation in Swift.
Stars: ✭ 21 (-51.16%)
Mutual labels:  observables
proc-that
proc(ess)-that - easy extendable ETL tool for Node.js. Written in TypeScript.
Stars: ✭ 25 (-41.86%)
Mutual labels:  observables
Angular Nodejs Mongodb Customersservice
Code for the Integrating Angular with Node.js RESTful Services Pluralsight course.
Stars: ✭ 164 (+281.4%)
Mutual labels:  observables
Documentation
How does it all fit together?
Stars: ✭ 177 (+311.63%)
Mutual labels:  observables
electron-RxDB
RxDB is a high-performance, observable object store built on top of SQLite & intended for database-driven Electron applications.
Stars: ✭ 68 (+58.14%)
Mutual labels:  observables
Asynquence
Asynchronous flow control (promises, generators, observables, CSP, etc)
Stars: ✭ 1,737 (+3939.53%)
Mutual labels:  observables
indefinite-observable-js
An Observable for JavaScript that never calls complete or error
Stars: ✭ 62 (+44.19%)
Mutual labels:  observables
Rxios
A RxJS wrapper for axios
Stars: ✭ 119 (+176.74%)
Mutual labels:  observables
observer-spy
This library makes RxJS Observables testing easy!
Stars: ✭ 310 (+620.93%)
Mutual labels:  observables
jasmine-marbles
Marble testing helpers for RxJS and Jasmine
Stars: ✭ 102 (+137.21%)
Mutual labels:  observables
zen-signals
☯ The simplest signal library possible
Stars: ✭ 41 (-4.65%)
Mutual labels:  observables
servable
"simple" observable implementation based off RxJS & kefir Docs
Stars: ✭ 14 (-67.44%)
Mutual labels:  observables

Snail-Kotlin 🐌 Bitrise codecov

A lightweight observables framework, also available in Swift

Download

You can download a jar from GitHub's releases page.

Jitpack

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

dependencies {
  compile 'com.github.urbancompass:snail-kotlin:x.x.x'
}

Creating Observables

val observable = Observable<thing>()

Subscribing to Observables

observable.subscribe(
    next = { thing in ... }, // do something with thing
    error = { error in ... }, // do something with error
    done = { ... } // do something when it's done
)

Closures are optional too...

observable.subscribe(
    next = { thing in ... } // do something with thing
)
observable.subscribe(
    error = { error in ... } // do something with error
)

Creating Observables Variables

val variable = Variable<whatever>(some initial value)
val optionalString = Variable<String?>(null)
optionalString.asObservable().subscribe(
    next = { string in ... } // do something with value changes
)

optionalString.value = "something"
val int = Variable<Int>(12)
int.asObservable().subscribe(
    next = { int in ... } // do something with value changes
)

int.value = 42

Miscellaneous Observables

val just = Just(1) // always returns the initial value (1 in this case)

val failure = Fail(RunTimeException()) // always returns error
failure.subscribe(
	error = { it }  //it is RuntimeException
)

val n = 5
let replay = Replay(n) // replays the last N events when a new observer subscribes

Dispatchers

You can specify which dispatcher an observables will be notified on by using .subscribe(dispatcher: <desired dispatcher>). If you don't specify, then the observable will be notified on the same dispatcher that the observable published on.

There are 3 scenarios:

  1. You don't specify the dispatcher. Your observer will be notified on the same dispatcher as the observable published on.

  2. You specified Main dispatcher AND the observable published on the Main dispatcher. Your observer will be notified synchronously on the Main dispatcher.

  3. You specified a dispatcher. Your observer will be notified async on the specified dispatcher.

Examples

Subscribing on Main

observable.subscribe(Dispatchers.Main, next = {
    // do stuff with it...
})
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].