All Projects → uzimaru0000 → UniTEA

uzimaru0000 / UniTEA

Licence: MIT, Unknown licenses found Licenses found MIT LICENSE Unknown LICENSE.meta
Implementation of The Elm Architecture for Unity3D

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to UniTEA

Teapot
Unidirectional Dataflow library for Android inspired by The Elm Architecture
Stars: ✭ 29 (-6.45%)
Mutual labels:  state-management, elm-architecture
alveron-old
Opinionated Elm-inspired Redux Component Architecture for React
Stars: ✭ 17 (-45.16%)
Mutual labels:  state-management, elm-architecture
Hydux
A light-weight type-safe Elm-like alternative for Redux ecosystem, inspired by hyperapp and Elmish
Stars: ✭ 216 (+596.77%)
Mutual labels:  state-management, elm-architecture
tuxi
✨ White glove service for your async needs
Stars: ✭ 14 (-54.84%)
Mutual labels:  state-management
bloc
A predictable state management library that helps implement the BLoC design pattern
Stars: ✭ 12 (-61.29%)
Mutual labels:  state-management
atomic-state
Atomic State is a state management library for React
Stars: ✭ 15 (-51.61%)
Mutual labels:  state-management
XUI
XUI makes modular, testable architectures for SwiftUI apps a breeze!
Stars: ✭ 100 (+222.58%)
Mutual labels:  state-management
swr-internal-state
Use SWR to manage app's internal state
Stars: ✭ 32 (+3.23%)
Mutual labels:  state-management
asyncmachine
Relational State Machine with a visual inspector
Stars: ✭ 67 (+116.13%)
Mutual labels:  state-management
storken
🦩 Storken is a React State Manager. Simple as `useState`.
Stars: ✭ 22 (-29.03%)
Mutual labels:  state-management
quick-redux
helper functions to make redux and react development quicker
Stars: ✭ 61 (+96.77%)
Mutual labels:  state-management
crypto-currency
A Flutter application showing crypto currency rates.
Stars: ✭ 16 (-48.39%)
Mutual labels:  state-management
mst-effect
💫 Designed to be used with MobX-State-Tree to create asynchronous actions using RxJS.
Stars: ✭ 19 (-38.71%)
Mutual labels:  state-management
larch
An Elm-like ClojureScript framework
Stars: ✭ 37 (+19.35%)
Mutual labels:  elm-architecture
NObservable
MobX like observable state management library with Blazor support
Stars: ✭ 66 (+112.9%)
Mutual labels:  state-management
screenmanager
Stackable Screen/State Management for the LÖVE framework.
Stars: ✭ 29 (-6.45%)
Mutual labels:  state-management
almy
🗄️ 673 bytes store for managing the state in your application
Stars: ✭ 26 (-16.13%)
Mutual labels:  state-management
yurt
high quality mounted real (e)states
Stars: ✭ 53 (+70.97%)
Mutual labels:  state-management
tea-chess
A chess-themed tutorial on writing an SPA in Bucklescript-TEA
Stars: ✭ 28 (-9.68%)
Mutual labels:  elm-architecture
gstate
A crazy state management for lazy programmers
Stars: ✭ 27 (-12.9%)
Mutual labels:  state-management

logo

UniTEA is an implementation of The Elm Architecture for Unity3D.

Environment

  • Unity3D 2018.4 or higher
  • C# 7.0

Install

Add line in Packages/manifest.json

{
  "dependencies" : {
    ...
    "com.uzimaru0000.unitea": "https://github.com/uzimaru0000/UniTEA.git",
    ...
  }
}

Usage

  1. Create your application Model. You should use struct.

    public struct Model
    {
       public int count;
    }
  2. Create a message for your application. You should use enum.

    public enum Msg
    {
    	Increase,
    	Decrease
    }
  3. Create a class that wraps the message. Implement the IMessenger<Msg> interface.

    using UniTEA;
    
    public class IncreaseMsg : IMessenger<Msg>
    {
    	public Msg GetMessage() => Msg.Increase;
    }
    
    public class DecreaseMsg : IMessenger<Msg>
    {
    	public Msg GetMessage() => Msg.Decrease;
    }
  4. Create Updater class. Implement the IUpdater<Model, Msg> interface.

    using UniTEA;
    
    public class Updater : IUpdater<Model, Msg>
    {
    	public (Model, Cmd<Msg>) Update(IMessenger<Msg> msg, Model model)
    	{
    		switch (msg)
    		{
    			case IncreaseMsg _:
    				return (new Model
    				{
    					count = model.count + 1;
    				}, Cmd<Msg>.none);
    			case DecreaseMsg _:
    				return (new Model
    				{
    					count = model.count - 1;
    				}, Cmd<Msg>.none);
    			default:
    				return (model, Cmd<Msg>.none);
    		}
    	}
    }
  5. Create Renderer class. Implement the IRenderer<Model, Msg> interface.

    using UnityEngine;
    using UnityEngine.UI;
    using UniTEA;
    
    public class Renderer : MonoBehaviour, IRenderer<Model>
    {
    	[SerializeField]
    	Text display;
       [SerializeField]
       Button increaseBtn;
       [SerializeField]
       Button decreaseBtn;
    
       public void Init(System.Action<IMessenger<Msg>> dispatcher)
       {
          increaseBtn.onClick.AddListener(() => dispatcher(new IncreaseMsg()));
          decreaseBtn.onClick.AddListener(() => dispatcher(new DecreaseMsg()));
       }
    
    	public void Renderer(Model model)
    	{
    		display.text = model.count.ToString();
    	}
    }
  6. 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.

    using UniTEA;
    using UnityEngine;
    
    public class TEAManager : MonoBehaviour
    {
    	UniTEA<Model, Msg> tea;
    
    	[SerializeField]
    	new Renderer renderer;
    
    	void Start()
    	{
    		tea = new TEA<Model, Msg>(
    			() => (new Model(), Cmd<Msg>.none),
    			new Updater(),
    			renderer
    		);
    	}
    }

Example

TODO: Coming soon!

I'm happy if you contribute!

Development

  1. Make your project and make directory Packages in it.
  2. In Packages, git clone https://github.com/uzimaru0000/UniTEA.git
  3. Install UniTEA from clone.

Contribution

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].