{"id":25631916,"url":"https://github.com/ivianuu/simple-mvvm","last_synced_at":"2026-04-21T13:01:38.325Z","repository":{"id":94685836,"uuid":"93655327","full_name":"IVIanuu/simple-mvvm","owner":"IVIanuu","description":"[DEPRECATED] Simple mvvm implementation for android inspired by kickstarter","archived":false,"fork":false,"pushed_at":"2017-09-09T12:06:08.000Z","size":165,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T20:34:41.099Z","etag":null,"topics":["activity","android","fragments","java","mvvm","mvvm-architecture","rxjava","rxlifecycle","viewmodel","viewmodel-pattern"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"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/IVIanuu.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":"2017-06-07T16:15:38.000Z","updated_at":"2018-06-19T22:20:46.000Z","dependencies_parsed_at":"2023-07-29T02:45:24.595Z","dependency_job_id":null,"html_url":"https://github.com/IVIanuu/simple-mvvm","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/IVIanuu/simple-mvvm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IVIanuu%2Fsimple-mvvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IVIanuu%2Fsimple-mvvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IVIanuu%2Fsimple-mvvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IVIanuu%2Fsimple-mvvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IVIanuu","download_url":"https://codeload.github.com/IVIanuu/simple-mvvm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IVIanuu%2Fsimple-mvvm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32093156,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T11:25:29.218Z","status":"ssl_error","status_checked_at":"2026-04-21T11:25:28.499Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["activity","android","fragments","java","mvvm","mvvm-architecture","rxjava","rxlifecycle","viewmodel","viewmodel-pattern"],"created_at":"2025-02-22T20:31:54.072Z","updated_at":"2026-04-21T13:01:38.315Z","avatar_url":"https://github.com/IVIanuu.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SimpleMVVM\nBase MVVM implementation for android inspired by kickstarter.\n\n## Introduction\nThis library uses the architecture component internally.\nLearn more: https://developer.android.com/topic/libraries/architecture/viewmodel.html\n\n## Download\n```groovy\n// in your root gradle\nallprojects {\n\trepositories {\n\t\t...\n\t\tmaven { url 'https://jitpack.io' }\n\t}\n}\n```\n\n```groovy\ndependencies {\n\t compile 'com.github.IVIanuu:SimpleMVVM:LATEST-VERSION'\n}\n```\n\n## Usage\n\nThis example uses a activity but it works the same for fragments(Just replace Activity with Fragment).\nFirst create a view model it needs to extend SimpleMVVMActivityViewModel.\n\n```java\npublic class LoginActivityViewModel extends MVVMActivityViewModel {\n\n    public LoginActivityViewModel() {\n       \n    }\n    \n    public void login() {\n      // todo implement login\n    }\n}\n```\n\nThen create your activity class. The activity needs to extend SimpleMVVMActivity\u003cMyViewModel\u003e\nand must be annotated with a @RequiresActivityViewModel(MyViewModel.class) annotation.\n\n```java\n@RequiresActivityViewModel(LoginActivityViewModel.class)\npublic class LoginActivity extends MVVMActivity\u003cLoginActivityViewModel\u003e {\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_login);\n\n        // use your view model here\n\tviewModel.login();\n    }\n    \n    ...\n    \n}\n```\nBy default the library will use the default ViewModelProvider.Factory. \nIf you want to use your own (For example to inject dependencies in your view model via dagger) you have to override the provideViewModelFactory method like this.\n\n```java\n@RequiresActivityViewModel(LoginActivityViewModel.class)\npublic class LoginActivity extends MVVMActivity\u003cLoginActivityViewModel\u003e {\n\n    ...\n\n    @Override\n    protected ViewModelProvider.Factory provideViewModelFactory() {\n        return mySuperCoolViewModelFactory;\n    }\n}\n```\nThe library is meant to be used with rxjava and for convenience it includes RxLifecycle from trello so you can easily bind your observables to the lifecycle of your activities, fragments or view models. This should look like the following.\n\n```java\n@RequiresActivityViewModel(DetailActivityViewModel.class)\npublic class DetailActivity extends MVVMActivity\u003cDetailActivityViewModel\u003e {\n\n     @Override\n    protected void onCreate(Bundle savedInstanceState) {\n       \n        ...\n\t\n\tviewModel.loadData()\n                .compose(bindToLifecycle()) // will complete the observable in onDestroy\n\t\t.compose(bindUntilEvent(Lifecycle.Event.ON_PAUSE)) // will complete the observable in onPause\n                .subscribe()\n    }\n}\n```\nIn view models the observable completes in onCleared which will be called when your activity or fragment will be destroyed.\n\n```java\npublic class DetailActivityViewModel extends MVVMActivityViewModel {\n\n    private final MyCoolRepository repo;\n\n    @Inject\n    public DetailActivityViewModel(@NonNull MyCoolRepository repo) {\n           this.repo = repo;\n\t\n\t   repo.loadDetails()\n                .compose(bindToLifecycle()) // will complete the observable onCleared\n                .subscribe(data -\u003e {\n                    // do something cool with your data\n                });\n    }\n}\n```\n\nYou can observe new intents and activity results in your activity view models.\n\n```java\n public class CommentActivityViewModel extends MVVMActivityViewModel {\n\n        private static final int REQUEST_CODE = 1234;\n        \n        public CommentActivityViewModel() {\n            \n            intent()\n                    .compose(bindToLifecycle())\n                    .subscribe(intent -\u003e {\n                        // do something with the intent\n                    });\n            \n            activityResult()\n                    .compose(bindToLifecycle())\n                    .filter(activityresult -\u003e activityresult.isRequestCode(REQUEST_CODE))\n                    .subscribe(activityResult -\u003e {\n                        // do something with the activity result\n                    });\n        }\n    }\n```\n\nIn fragment view models you can observe arguments.\n\n```java\n public class ProfileFragmentViewModel extends MVVMFragmentViewModel {\n\n        private static final int REQUEST_CODE = 1234;\n        \n        public ProfileFragmentViewModel() {\n            \n            arguments()\n                    .compose(bindToLifecycle())\n                    .subscribe(bundle -\u003e {\n                        // do something with the bundle\n                    });\n\t\t    \n        }\n}\n```\n\n## License\n\n```\nCopyright 2017 Manuel Wrage\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n \nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivianuu%2Fsimple-mvvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivianuu%2Fsimple-mvvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivianuu%2Fsimple-mvvm/lists"}