A small library that provides helper functions to work with Janet in Kotlin.
Grab via Maven
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.techery</groupId>
<artifactId>janet-kotlin</artifactId>
<version>latestVersion</version>
</dependency>
or Gradle:
repositories {
...
maven { url "https://jitpack.io" }
}
dependencies {
compile 'com.github.techery:janet-kotlin:latestVersion'
}
Janet
val janet1 = janet(service1, service2, service3)
val janet2 = janet {
addService(service1)
addService(service2)
addService(service3)
}
ActionServiceWrapper
class SimpleServiceWrapper(actionService: ActionService) : ActionServiceWrapper(actionService, {
onInterceptStart {
println("onInterceptStart#1 $it")
}
onInterceptStart {
println("onInterceptStart#2 $it")
}
onInterceptSuccess { actionHolder ->
println("onInterceptSuccess $actionHolder")
}
})
var service: ActionService = SomeActionService().wrap {
onInterceptStart {
println("onInterceptStart#1 $it")
}
onInterceptStart {
println("onInterceptStart#2 $it")
}
onInterceptSuccess { actionHolder ->
println("onInterceptSuccess $actionHolder")
}
}
ActionPipe
val pipe: ActionPipe<SimpleAction> = janet.createPipe()
val pipe2: ActionPipe<SimpleAction> = janet.createPipe(Schedulers.io())
ActionStateSubscriber
pipe.createObservable(SimpleAction())
.subscribeAction {
onStart {
println("started")
}
onSuccess {
println("success")
}
onFail { action, throwable ->
println("fail $throwable")
}
}
ActionStateToActionTransformer
pipe.createObservable(SimpleAction())
.mapToResult()
.subscribe()
Observable<ActionState<*>>
pipe.observe()
.takeUntil(SUCCESS, FAIL)
.subscribe()