{"id":36417154,"url":"https://github.com/xlopec/tea-bag","last_synced_at":"2026-04-05T17:03:07.199Z","repository":{"id":39696009,"uuid":"188455731","full_name":"Xlopec/Tea-bag","owner":"Xlopec","description":"TEA implementation in Kotlin","archived":false,"fork":false,"pushed_at":"2025-12-03T14:24:30.000Z","size":7263,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-06T18:52:17.018Z","etag":null,"topics":["android","android-architecture","android-library","elm-architecture","kotlin","tea"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Xlopec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-05-24T16:35:55.000Z","updated_at":"2024-10-09T14:35:15.000Z","dependencies_parsed_at":"2024-09-13T01:45:09.414Z","dependency_job_id":"c87e0694-ed2f-4a1a-866a-137bc9e2f907","html_url":"https://github.com/Xlopec/Tea-bag","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/Xlopec/Tea-bag","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xlopec%2FTea-bag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xlopec%2FTea-bag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xlopec%2FTea-bag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xlopec%2FTea-bag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Xlopec","download_url":"https://codeload.github.com/Xlopec/Tea-bag/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xlopec%2FTea-bag/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28314254,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-architecture","android-library","elm-architecture","kotlin","tea"],"created_at":"2026-01-11T17:00:19.093Z","updated_at":"2026-04-05T17:03:07.185Z","avatar_url":"https://github.com/Xlopec.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Maven Central](https://img.shields.io/maven-central/v/io.github.xlopec/tea-core?style=plastic\u0026versionPrefix=1.0.0-alpha10)](https://mvnrepository.com/artifact/io.github.xlopec/tea-core)\n[![Jetbrains Market Place](https://img.shields.io/jetbrains/plugin/d/14254)](https://plugins.jetbrains.com/plugin/14254-time-travel-debugger)\n\n# TEA Bag\n\n\u003cimg align=\"right\" alt=\"Tea Bag Logo\" height=\"200px\" src=\"res/tea-bag-logo.png\"\u003e\n\nTea Bag is a simple implementation of [TEA](https://guide.elm-lang.org/architecture/)\narchitecture written in Kotlin. This library is based on Kotlin's coroutines, extensively uses\nextension-based approach and supports many targets including ```jvm```, ```js```, ```wasmJs```, ```ios```, ```macos```, ```tvos```,\n```watchos```, ```linux``` and ```mingw```.\n\nThis library is designed to be a lightweight, simple, and multiplatform-first implementation of\nthe TEA architecture. It provides a minimal set of abstractions to build TEA app\n\n## Quick Sample\n\nNothing special: we just need to code our initializer, resolver (`tracker` function),\nupdater (`computeNewState` function), and UI (`renderSnapshot` function). After that, we should pass\nthem to an appropriate `Component` builder overload.\n\n```kotlin\n@file:OptIn(ExperimentalTeaApi::class)\n\npackage io.github.xlopec.counter\n\nimport io.github.xlopec.tea.core.*\nimport kotlinx.coroutines.runBlocking\n\n/**Async initializer, provides initial state*/\nsuspend fun initializer(): Initial\u003cInt, Int\u003e = Initial(0)\n\n/**Some tracker*/\nfun track(\n  event: Snapshot\u003cInt, Int, Int\u003e,\n  ctx: ResolveCtx\u003cInt\u003e,\n) {\n  ctx sideEffect { println(\"Track: \\\"$event\\\"\") }\n}\n\n/**App logic, for now it just adds delta to count and returns this as result*/\nfun add(\n  delta: Int,\n  counter: Int,\n): Update\u003cInt, Int\u003e = (counter + delta) command delta\n\n/**Some UI, e.g. console*/\nsuspend fun display(\n  snapshot: Snapshot\u003c*, *, *\u003e,\n) {\n  println(\"Display: $snapshot\")\n}\n\nfun main() = runBlocking {\n  // Somewhere at the application level\n  val component = Component(\n    initializer = ::initializer,\n    resolver = ::track,\n    updater = ::add,\n    scope = this,\n  )\n  // UI = component([message1, message2, ..., message N])\n  component(+1, +2, -3).collect(::display)\n}\n```\n\nThe sample above will print the following:\n\n```text\nDisplay: Initial(currentState=0, commands=[])\nTrack: \"Regular(currentState=1, commands=[1], previousState=0, message=1)\"\nTrack: \"Initial(currentState=0, commands=[])\"\nTrack: \"Regular(currentState=3, commands=[2], previousState=1, message=2)\"\nTrack: \"Regular(currentState=0, commands=[-3], previousState=3, message=-3)\"\nDisplay: Regular(currentState=1, commands=[1], previousState=0, message=1)\nDisplay: Regular(currentState=3, commands=[2], previousState=1, message=2)\nDisplay: Regular(currentState=0, commands=[-3], previousState=3, message=-3)\n```\n\nReal-world examples include [Android](https://github.com/Xlopec/Tea-bag/tree/master/samples/app) and\n[iOS](https://github.com/Xlopec/Tea-bag/tree/master/samples/iosApp) app samples that use the same application component\nand share common entities, application, and navigation logic.\n[IntelliJ plugin](https://github.com/Xlopec/Tea-bag/tree/master/tea-time-travel-plugin) is built on top of the library\nas well.\n\nFor more info, visit the [Wiki](https://github.com/Xlopec/Tea-bag/wiki) page.\n\n## Main Features\n\n- **Multiplatform** this library supports ```jvm```, ```js```, ```wasmJs```, ```ios```, ```macos```, ```tvos```, ```watchos```, ```linux```\n  and ```mingw``` targets\n- **Scalability** it is build on the top of a simple idea of having pure functions that operate on\n  plain data separated from impure one. Those functions are building blocks and form testable\n  components that can be combined to build complex applications\n- **Simplicity** component implementation resides in a single file\n- **Extensibility** additional functionality and API is implemented as component extensions which\n  means you can easily add your own\n- **Debugger** [Intellij debugger plugin](https://plugins.jetbrains.com/plugin/14254-time-travel-debugger)\n  is available for this library, though it's not production ready yet\n\n## Gradle\n\nAdd the dependency:\n\n```kotlin\nimplementation(\"io.github.xlopec:tea-core:[version]\")\nimplementation(\"io.github.xlopec:tea-compose:[version]\")\nimplementation(\"io.github.xlopec:tea-navigation:[version]\")\n```\n\nMake sure that you have `mavenCentral()` in the list of repositories.\n\n## Plugin\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"Demo\" src=\"res/demo.gif\"\u003e\n\u003c/p\u003e\n\nPlugin is available on [JetBrains marketplace](https://plugins.jetbrains.com/plugin/14254-time-travel-debugger)\n\n## Main Modules\n\n- **tea-core** - contains core types along with basic component implementation\n- **tea-compose** - contains Compose Multiplatform integration\n- **tea-navigation** - contains navigation extensions as well as predictive back navigation for iOS target\n- **tea-time-travel** - contains debuggable version of the component\n- **tea-time-travel-adapter-gson** - implements debug protocol and serialization by means\n  of [Gson](https://github.com/google/gson) library. Should be added as dependency together with **tea-time-travel** module\n- **tea-time-travel-protocol** - contains debug protocol types definitions\n\n## How to build and run\n\nTo build the plugin from sources, use the ```./gradlew tea-time-travel-plugin:buildPlugin``` command.\nThe installable plugin will be located in the ```tea-time-travel-plugin/build/distributions``` directory.\n\nTo run IntelliJ IDEA with the installed plugin, use the ```./gradlew tea-time-travel-plugin:runIde```\ncommand.\n\nTo build the Android app sample, run ```./gradlew :samples:app:assembleDefaultDebug``` or ```./gradlew :samples:app:assembleRemoteDebug```.\nThe last command assembles a debuggable version of the application that connects to the currently running instance of\nthe debugger (will try connecting to http://localhost:8080).\n\n## Planned features and TODOs\n\n- Re-implement client-server communication protocol from scratch.\n- Migrate from Gson to `kotlinx.serialization.json`.\n- Release v1.0.0.\n- Add GitHub Wiki.\n- Rework component builders and possibly replace them with some kind of DSL.\n- Add keyboard shortcuts for the plugin; consider improving plugin UX.\n\n## Contribution\n\nContributions are more than welcome. If something cannot be done, is not convenient, or does not work -\ncreate an issue or PR.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxlopec%2Ftea-bag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxlopec%2Ftea-bag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxlopec%2Ftea-bag/lists"}