{"id":17651157,"url":"https://github.com/jeziellago/coroutinesflowext","last_synced_at":"2025-05-07T07:10:00.280Z","repository":{"id":126467631,"uuid":"261025884","full_name":"jeziellago/CoroutinesFlowExt","owner":"jeziellago","description":"Reactive components with Kotlin Flow 🛠","archived":false,"fork":false,"pushed_at":"2020-06-28T20:11:35.000Z","size":69,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-07T07:09:45.617Z","etag":null,"topics":["coroutines","kotlin","kotlin-coroutines","kotlin-flow","reactive-components"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeziellago.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}},"created_at":"2020-05-03T21:38:13.000Z","updated_at":"2020-09-30T21:26:35.000Z","dependencies_parsed_at":"2023-06-16T22:15:38.611Z","dependency_job_id":null,"html_url":"https://github.com/jeziellago/CoroutinesFlowExt","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeziellago%2FCoroutinesFlowExt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeziellago%2FCoroutinesFlowExt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeziellago%2FCoroutinesFlowExt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeziellago%2FCoroutinesFlowExt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeziellago","download_url":"https://codeload.github.com/jeziellago/CoroutinesFlowExt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252831257,"owners_count":21810783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["coroutines","kotlin","kotlin-coroutines","kotlin-flow","reactive-components"],"created_at":"2024-10-23T11:40:27.955Z","updated_at":"2025-05-07T07:10:00.272Z","avatar_url":"https://github.com/jeziellago.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CoroutinesFlowExt\nReactive components with Kotlin Flow\n\n### FlowPublisher / FlowSubscriber\n```kotlin\n// Publisher\nval publisher = flowPublisher {\n    emit(1)\n    emit(2)\n    emit(3)\n}\n\n// or create publisher from source Flow\nval myFlowEmitter = flow { emit(1) } // \"source\" Flow (emitter)\n\nval publisher = FlowPublisher(source = myFlowEmitter)\n\n// or use Flow extension\nval publisher = myFlowEmitter.asPublisher()\n```\n\n```kotlin\n// Create Subscribers\n\n// use `flowSubscriberOf`\nval subscriberA = flowSubscriberOf\u003cInt\u003e(publisher)\n\n// or\nval subscriberB = FlowSubscriber\u003cInt\u003e()\npublisher.subscribe(subscriberB)\n```\n\n```kotlin\n// Receive values as Flow\nval flowFromA = subscriberA.asFlow()\nval flowFromB = subscriberB.asFlow()\n```\n\n```kotlin\n// Start emitter from publisher \npublisher.open()\n```\n```kotlin\n// Unsubscribe any receiver\npublisher.unsubscribe(subscriberA)\n```\n\n### FlowEmitter\n```kotlin\nval emitter = FlowEmitter\u003cInt\u003e()\n\n// use emitter as FlowPublisher\nval flowPublisher = emitter.asPublisher()\n\n// emit values\nemitter.emit(1)\nemitter.emit(2)\nemitter.emit(3)\n...\n```\n### Easy collect using StateFlow\nUse `observeState`:\n```kotlin\ncoroutineScope.observeState(stateFlow) {\n  // collect value\n}\n``` \nInstead of:\n```kotlin\ncoroutineScope.launch {\n    stateFlow.collect {\n        // collect value\n    }\n}\n```\n\n## Add dependencies\n- Project `build.gradle` \n```\nallprojects {\n    repositories {\n        ...\n        maven { url 'https://jitpack.io' }\n    }\n}\n```\n- Module `build.gradle` \n```\ndependencies {\n    implementation 'com.github.jeziellago:CoroutinesFlowExt:0.1.2'\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeziellago%2Fcoroutinesflowext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeziellago%2Fcoroutinesflowext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeziellago%2Fcoroutinesflowext/lists"}