StateVariable 1.2.5

dotnet add package StateVariable --version 1.2.5                
NuGet\Install-Package StateVariable -Version 1.2.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="StateVariable" Version="1.2.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StateVariable --version 1.2.5                
#r "nuget: StateVariable, 1.2.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install StateVariable as a Cake Addin
#addin nuget:?package=StateVariable&version=1.2.5

// Install StateVariable as a Cake Tool
#tool nuget:?package=StateVariable&version=1.2.5                

license

nuget

Mission of this Library

  • To provide a simple and easy-to-use state management library for Unity.(Like Redux or Svelte.store)

Features 🌟

  • Variable Set/Read/Observe
  • VariableCollection
  • DependencyVariable/HalfDependencyVariable

Variable List

class summary implements interface
ObservableVariable <br/>SubjectVariable A state variable that can be observed IVariableReader, IVariableObserver, IVariableSetter, IDisposable
Variable A state variable that cannot be observed but is more memory-efficient than ObservableVariable IVariableReader, IVariableSetter
DependencyVariable A variable that derives results from other variables and triggers them IVariableReader, IVariableObserver
HalfDependencyVariable A Variable that derive results from other variables and their own variable and trigger them IVariableReader, IVariableSetter, IVariableObserver
ObservableListVariable A collection of Variables (internally implemented as a List) IVariableReader, IVariableSetter, IVariableCollectionObserver, IVariableCollectionElementObserver, IVariableCollectionElementSetter, IVariableCollectionModifier
ObservableDictionaryVariable A collection of Variables (internally implemented as a Dictionary) IVariableReader, IVariableSetter, IVariableCollectionObserver, IVariableCollectionElementObserver, IVariableCollectionElementSetter, IVariableCollectionModifier

Usage Example(This Example used a Zenject)

Each Variable is bound to the appropriate context of the DI container, and each object obtains the necessary dependencies.


// ----- Installer
var testVariable = new ObservableVariable<Test>(new Test());
testVariable.AddTo(this);
Container.BindInstance<IVariableReader<Test>>(testVariable);
Container.BindInstance<IVariableObserver<Test>>(testVariable);
Container.BindInstance<IVariableSetter<Test>>(testVariable);

[Inject] IVariableObserver<Test> _testObserver;
[Inject] IVariableReader<Test> _testReader;
[Inject] IVariableSetter<Test> _testSetter;

void Start()
{
    // How to use variable
    _testObserver.Observe().Subscribe(test => {}).AddTo(this);
    Test test = _testReader.Read();
    _testSetter.Set(new Test());

    // Observer can also read
    test = _testObserver.Read();

    // Setter can also read
    test = _testSetter.Read();
}

Installation ☘️

Install via nuget

  1. Run the following:
dotnet add package StateVariable --version 1.2.5

Required

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.5 68 11/3/2024
1.2.4 127 9/3/2024