{"id":16040144,"url":"https://github.com/uzimaru0000/unitea","last_synced_at":"2025-03-17T16:31:22.941Z","repository":{"id":88419442,"uuid":"194786435","full_name":"uzimaru0000/UniTEA","owner":"uzimaru0000","description":"Implementation of The Elm Architecture for Unity3D","archived":false,"fork":false,"pushed_at":"2020-06-12T22:30:00.000Z","size":1624,"stargazers_count":32,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T01:47:46.874Z","etag":null,"topics":["cshape","elm-architecture","framework","state-management","unity3d"],"latest_commit_sha":null,"homepage":"","language":"C#","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/uzimaru0000.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":"2019-07-02T04:09:40.000Z","updated_at":"2024-12-04T13:16:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"f60e1e2e-beb0-4360-aede-d1c7ecfa358e","html_url":"https://github.com/uzimaru0000/UniTEA","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uzimaru0000%2FUniTEA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uzimaru0000%2FUniTEA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uzimaru0000%2FUniTEA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uzimaru0000%2FUniTEA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uzimaru0000","download_url":"https://codeload.github.com/uzimaru0000/UniTEA/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243871644,"owners_count":20361378,"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":["cshape","elm-architecture","framework","state-management","unity3d"],"created_at":"2024-10-08T23:09:46.848Z","updated_at":"2025-03-17T16:31:22.934Z","avatar_url":"https://github.com/uzimaru0000.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ![logo](./images/logo.png)\n\nUniTEA is an implementation of The Elm Architecture for Unity3D.\n\n## Environment\n\n- Unity3D 2018.4 or higher\n- C# 7.0\n\n## Install\n\nAdd line in Packages/manifest.json\n\n```json\n{\n  \"dependencies\" : {\n    ...\n    \"com.uzimaru0000.unitea\": \"https://github.com/uzimaru0000/UniTEA.git\",\n    ...\n  }\n}\n```\n\n## Usage\n\n1. Create your application Model. You should use struct.\n\n   ```c#\n   public struct Model\n   {\n      public int count;\n   }\n   ```\n\n2. Create a message for your application. You should use enum.\n\n   ```c#\n   public enum Msg\n   {\n   \tIncrease,\n   \tDecrease\n   }\n   ```\n\n3. Create a class that wraps the message. Implement the `IMessenger\u003cMsg\u003e` interface.\n\n   ```c#\n   using UniTEA;\n\n   public class IncreaseMsg : IMessenger\u003cMsg\u003e\n   {\n   \tpublic Msg GetMessage() =\u003e Msg.Increase;\n   }\n\n   public class DecreaseMsg : IMessenger\u003cMsg\u003e\n   {\n   \tpublic Msg GetMessage() =\u003e Msg.Decrease;\n   }\n   ```\n\n4. Create Updater class. Implement the `IUpdater\u003cModel, Msg\u003e` interface.\n\n   ```c#\n   using UniTEA;\n\n   public class Updater : IUpdater\u003cModel, Msg\u003e\n   {\n   \tpublic (Model, Cmd\u003cMsg\u003e) Update(IMessenger\u003cMsg\u003e msg, Model model)\n   \t{\n   \t\tswitch (msg)\n   \t\t{\n   \t\t\tcase IncreaseMsg _:\n   \t\t\t\treturn (new Model\n   \t\t\t\t{\n   \t\t\t\t\tcount = model.count + 1;\n   \t\t\t\t}, Cmd\u003cMsg\u003e.none);\n   \t\t\tcase DecreaseMsg _:\n   \t\t\t\treturn (new Model\n   \t\t\t\t{\n   \t\t\t\t\tcount = model.count - 1;\n   \t\t\t\t}, Cmd\u003cMsg\u003e.none);\n   \t\t\tdefault:\n   \t\t\t\treturn (model, Cmd\u003cMsg\u003e.none);\n   \t\t}\n   \t}\n   }\n   ```\n\n5. Create Renderer class. Implement the `IRenderer\u003cModel, Msg\u003e` interface.\n\n   ```c#\n   using UnityEngine;\n   using UnityEngine.UI;\n   using UniTEA;\n\n   public class Renderer : MonoBehaviour, IRenderer\u003cModel\u003e\n   {\n   \t[SerializeField]\n   \tText display;\n      [SerializeField]\n      Button increaseBtn;\n      [SerializeField]\n      Button decreaseBtn;\n\n      public void Init(System.Action\u003cIMessenger\u003cMsg\u003e\u003e dispatcher)\n      {\n         increaseBtn.onClick.AddListener(() =\u003e dispatcher(new IncreaseMsg()));\n         decreaseBtn.onClick.AddListener(() =\u003e dispatcher(new DecreaseMsg()));\n      }\n\n   \tpublic void Renderer(Model model)\n   \t{\n   \t\tdisplay.text = model.count.ToString();\n   \t}\n   }\n   ```\n\n6. Create TEAManager class. Make it singleton if necessary. For the UniTEA object, provide an initialization function, an instance of Updater, and an instance of Renderer.\n\n   ```c#\n   using UniTEA;\n   using UnityEngine;\n\n   public class TEAManager : MonoBehaviour\n   {\n   \tUniTEA\u003cModel, Msg\u003e tea;\n\n   \t[SerializeField]\n   \tnew Renderer renderer;\n\n   \tvoid Start()\n   \t{\n   \t\ttea = new TEA\u003cModel, Msg\u003e(\n   \t\t\t() =\u003e (new Model(), Cmd\u003cMsg\u003e.none),\n   \t\t\tnew Updater(),\n   \t\t\trenderer\n   \t\t);\n   \t}\n   }\n   ```\n\n## Example\n\n**TODO: Coming soon!**\n\n**I'm happy if you contribute！**\n\n## Development\n\n1. Make your project and make directory Packages in it.\n2. In Packages, `git clone https://github.com/uzimaru0000/UniTEA.git`\n3. Install UniTEA from clone.\n\n## Contribution\n\n1. Fork it\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuzimaru0000%2Funitea","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuzimaru0000%2Funitea","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuzimaru0000%2Funitea/lists"}