Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nadako/tinkstatesharp
Handle those pesky states, now in C#
https://github.com/nadako/tinkstatesharp
csharp godot reactive state-management unity
Last synced: about 2 months ago
JSON representation
Handle those pesky states, now in C#
- Host: GitHub
- URL: https://github.com/nadako/tinkstatesharp
- Owner: nadako
- License: unlicense
- Created: 2022-11-19T10:02:54.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-07-26T11:55:29.000Z (5 months ago)
- Last Synced: 2024-10-25T09:49:52.656Z (about 2 months ago)
- Topics: csharp, godot, reactive, state-management, unity
- Language: C#
- Homepage: https://nadako.github.io/TinkStateSharp/
- Size: 11.7 MB
- Stars: 43
- Watchers: 2
- Forks: 1
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
[![Build](https://github.com/nadako/TinkStateSharp/actions/workflows/build.yml/badge.svg)](https://github.com/nadako/TinkStateSharp/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/nadako/TinkStateSharp/branch/master/graph/badge.svg?token=92NEEMYYBL)](https://codecov.io/gh/nadako/TinkStateSharp)# TinkState# - Reactive State Handling for C# (and Unity!)
An uncomplicated library for dealing with mutable state in a nice reactive way.
[Documentation](https://nadako.github.io/TinkStateSharp/).
Features:
- Lightweight and generic observable state primitives
- Efficient binding mechanism with support for per-frame batching
- Computed states with automatic update propagation
- Asynchronously computed states with async/await
- Out-of-the-box support for Unity with convenience helpers
- Experimental support for Godot!## Quick Peek
Here's a "hello world" teaser in Unity (source code below).
![](docs/helloworld.gif)
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](https://haxe.org/) library [tink_state](https://github.com/haxetink/tink_state) by Juraj Kirchheim ([@back2dos](https://github.com/back2dos)).
## [Unlicense](https://unlicense.org/)
This is free and unencumbered software released into the public domain.