{"id":18264755,"url":"https://github.com/reactcomponentkit/helloandroidrck","last_synced_at":"2025-10-30T03:12:06.167Z","repository":{"id":137750974,"uuid":"189349389","full_name":"ReactComponentKit/HelloAndroidRCK","owner":"ReactComponentKit","description":"Basic example for AndroidReactComponentKit","archived":false,"fork":false,"pushed_at":"2019-08-31T14:02:53.000Z","size":220,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T19:53:52.190Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ReactComponentKit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-05-30T05:11:27.000Z","updated_at":"2019-08-31T14:02:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"1cbb1817-b9ed-4024-bd04-b00e74594c9d","html_url":"https://github.com/ReactComponentKit/HelloAndroidRCK","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactComponentKit%2FHelloAndroidRCK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactComponentKit%2FHelloAndroidRCK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactComponentKit%2FHelloAndroidRCK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReactComponentKit%2FHelloAndroidRCK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ReactComponentKit","download_url":"https://codeload.github.com/ReactComponentKit/HelloAndroidRCK/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247958710,"owners_count":21024821,"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":[],"created_at":"2024-11-05T11:15:50.506Z","updated_at":"2025-10-30T03:12:01.145Z","avatar_url":"https://github.com/ReactComponentKit.png","language":"Kotlin","readme":"# HelloAndroidRCK\n\nBasic example for AndroidReactComponentKit :)\n\n![](./art/result.gif)\n\n## Actions\n\n```kotlin\ndata class ClickButtonAction(val message: String): Action\n```\n\n## State \n\n```kotlin\nsealed class Route {\n    object None: Route()\n    data class Alert(val message: String): Route()\n}\n\ndata class MainState(\n    val route: Route = Route.None\n): State() {\n    override fun copyState(): State {\n        return this.copy()\n    }\n}\n```\n\n## MainViewModel \u0026 Define Flow\n\n```kotlin\nclass MainViewModel(application: Application): RCKViewModel\u003cMainState\u003e(application) {\n\n    val route = Output\u003cRoute\u003e(Route.None)\n\n    override fun setupStore() {\n\n        initStore { store -\u003e\n            store.initialState(MainState())\n\n            store.flow\u003cClickButtonAction\u003e(\n                { state, action -\u003e\n                    state.copy(route = Route.Alert(action.message))\n                }\n            )\n        }\n\n    }\n\n    override fun on(newState: MainState) {\n        route.accept(newState.route).afterReset(Route.None)\n    }\n}\n```\n\n## MainActivity\n\n```kotlin\nclass MainActivity : AppCompatActivity() {\n\n    private lateinit var viewModel: MainViewModel\n    private val disposeBag: AutoDisposeBag by lazy {\n        AutoDisposeBag(this)\n    }\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n\n        viewModel = ViewModelProviders.of(this).get(MainViewModel::class.java)\n\n        verticalLayout {\n            lparams(matchParent, matchParent)\n            gravity = Gravity.CENTER\n            component(ButtonComponent(viewModel.token))\n        }\n\n        handleViewModelOutputs()\n    }\n\n    private fun handleViewModelOutputs() {\n        viewModel\n            .route\n            .asObservable()\n            .skip(1)\n            .subscribe {\n                handleRoute(it)\n            }\n            .disposedBy(disposeBag)\n    }\n\n    private fun handleRoute(route: Route) {\n        when(route) {\n            is Route.Alert -\u003e {\n                alert(route.message).show()\n            }\n            else -\u003e Unit\n        }\n    }\n}\n```\n\n## Button Component\n\n```kotlin\nclass ButtonComponent(token: Token): ViewComponent(token) {\n    private lateinit var button: Button\n\n    override fun layout(ui: org.jetbrains.anko.AnkoContext\u003cContext\u003e): View = with(ui) {\n        val layout = relativeLayout {\n            lparams(wrapContent, wrapContent)\n            button = button(\"Click Me\")\n        }\n\n        button.setOnClickListener {\n            dispatch(ClickButtonAction(\"Hello AndroidReactComponentKit :)\"))\n        }\n\n        return layout\n    }\n}\n```\n\n## MIT License\n\nThe MIT License (MIT)\n\nCopyright (c) 2016 Sungcheol Kim, [https://github.com/ReactComponentKit/HelloAndroidRCK](https://github.com/ReactComponentKit/HelloAndroidRCK)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactcomponentkit%2Fhelloandroidrck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freactcomponentkit%2Fhelloandroidrck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactcomponentkit%2Fhelloandroidrck/lists"}