https://github.com/atlassian-labs/flowbius
Kotlin Flow <-> Spotify Mobius interop
https://github.com/atlassian-labs/flowbius
kotlin kotlin-coroutines kotlin-coroutines-flow mobius
Last synced: about 1 month ago
JSON representation
Kotlin Flow <-> Spotify Mobius interop
- Host: GitHub
- URL: https://github.com/atlassian-labs/flowbius
- Owner: atlassian-labs
- License: apache-2.0
- Created: 2022-01-20T22:21:53.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-10T18:56:00.000Z (about 1 year ago)
- Last Synced: 2025-03-30T11:23:34.753Z (2 months ago)
- Topics: kotlin, kotlin-coroutines, kotlin-coroutines-flow, mobius
- Language: Kotlin
- Homepage:
- Size: 113 KB
- Stars: 59
- Watchers: 6
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Flowbius
[](LICENSE) [](CONTRIBUTING.md)
Flowbius provides interoperability extensions for using [Kotlin Flows](https://kotlinlang.org/docs/flow.html) with [Mobius](https://github.com/spotify/mobius). They allow conversion from Flows to Mobius types and vice versa, as well as utilities to setup Mobius loops using Flows.
Flowbius is analogous to what `mobius-rx` provides for RxJava/Mobius interoperability.
## Usage
Flowbius provides converters from Flow types to Mobius types:
```kotlin
// Flow -> EventSource
val eventSource = flowOf(1, 2, 3).asEventSource()// EventSource -> Flow
val flow = eventSource.asFlow()// FlowTransformer -> Connectable
val connectable = { source: Flow -> source.map { it.length } }.asConnectable()// Apply a Connectable to a Flow as a flatMap which merges emissions
val transformedFlow = flow.flatMapMerge(connectable)
```You can also create a Mobius loop with Flow-based subtype effect handler:
```kotlin
val loop = FlowMobius.loop(
update = UpdateLogic(),
effectHandler = subtypeEffectHandler {
addConsumer(::handleEffects)
addFunction(::effectToEvents)
}
).startFrom(Model())
```## Installation
You can retrieve Flowbius from [Maven Central](https://search.maven.org/artifact/com.trello.flowbius/flowbius).
```
implementation 'com.trello.flowbius:flowbius:0.1.3'
```## Tests
```
$ ./gradlew tests
```## Contributions
Contributions to Flowbius are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.
## License
Copyright (c) 2022 Atlassian and others.
Apache 2.0 licensed, see [LICENSE](LICENSE) file.
[](https://www.atlassian.com)