StateVariable 1.3.0

dotnet add package StateVariable --version 1.3.0                
NuGet\Install-Package StateVariable -Version 1.3.0                
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.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StateVariable --version 1.3.0                
#r "nuget: StateVariable, 1.3.0"                
#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.3.0

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

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 🌟

  • State Set/Read/Observe
  • StateCollection
  • DependencyState/HalfDependencyState

State List

class summary implements interface
ObservableState <br/>SubjectState A state variable that can be observed IStateReader, IStateObserver, IStateSetter, IDisposable
State A state variable that cannot be observed but is more memory-efficient than ObservableState IStateReader, IStateSetter
DependencyState A state variable that derives results from other variables and triggers them IStateReader, IStateObserver
HalfDependencyState A state variable that derive results from other variables and their own variable and trigger them IStateReader, IStateSetter, IStateObserver
ObservableListState A collection of StateVariables (internally implemented as a List) IStateReader, IStateSetter, IStateCollectionObserver, IStateCollectionElementObserver, IStateCollectionElementSetter, IStateCollectionModifier
ObservableDictionaryState A collection of StateVariables (internally implemented as a Dictionary) IStateReader, IStateSetter, IStateCollectionObserver, IStateCollectionElementObserver, IStateCollectionElementSetter, IStateCollectionModifier

Usage Example(This Example used a Zenject)

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


// ----- Installer
var testState = new ObservableState<Test>(new Test());
testState.AddTo(this);
Container.BindInstance<IStateReader<Test>>(testState);
Container.BindInstance<IStateObserver<Test>>(testState);
Container.BindInstance<IStateSetter<Test>>(testState);

[Inject] IStateObserver<Test> _testObserver;
[Inject] IStateReader<Test> _testReader;
[Inject] IStateSetter<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.3.0

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.3.0 42 11/20/2024
1.2.5 79 11/3/2024
1.2.4 129 9/3/2024