nadako / TinkStateSharp

Handle those pesky states, now in C#
https://nadako.github.io/TinkStateSharp/
The Unlicense
40 stars 1 forks source link
csharp godot reactive state-management unity

Build codecov

TinkState# - Reactive State Handling for C# (and Unity!)

An uncomplicated library for dealing with mutable state in a nice reactive way.

Documentation.

Features:

Quick Peek

Here's a "hello world" teaser in Unity (source code below).

Source Code ```cs using TinkState; using TMPro; using UnityEngine; public class HelloWorld : MonoBehaviour { [SerializeField] TMP_InputField nameInput; [SerializeField] TMP_Text greetingLabel; void Start() { // define piece of mutable observable state var name = Observable.State("World"); // bind the state two-ways to an input field name.Bind(nameInput.SetTextWithoutNotify); nameInput.onValueChanged.AddListener(newValue => name.Value = newValue); // derive automatically updated observable value from it var greeting = Observable.Auto(() => $"Hello, {name.Value}!"); // bind the auto-observable to a text field greeting.Bind(text => greetingLabel.text = text); } } ```

Status

BETA. Everything seems to be working and test coverage makes sure of it, but the code could use some polishing, naming review, performance audit. See also TODOs in the code.

Thanks

It is a C# port of an excellent Haxe library tink_state by Juraj Kirchheim (@back2dos).

Unlicense

This is free and unencumbered software released into the public domain.