StateVariable 1.2.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package StateVariable --version 1.2.4                
NuGet\Install-Package StateVariable -Version 1.2.4                
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.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StateVariable --version 1.2.4                
#r "nuget: StateVariable, 1.2.4"                
#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.4

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

openupm license

Features 🚀

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

Variable List

class summary implements interface
ObservableVariable 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

Concept

それぞれのVariableはDIコンテナの適切なContextにBindし、各Objectで必要な依存を取得します。


// ----- 任意のDIコンテナのInstaller(このコード例はZenject)
var testVariable = new ObservableVariable<Test>(new Test());
testVariable.AddTo(this);    // ObservableVariableは内部的にReactivePropertyを使用しているため、Dispose管理する必要がある
Container.BindInstance<IVariableReader<Test>>(testVariable);
Container.BindInstance<IVariableObserver<Test>>(testVariable);
Container.BindInstance<IVariableSetter<Test>>(testVariable);

// ----- 任意のObject内
[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はReadも可能
    test = _testObserver.Read();

    // SetterもReadできる
    test = _testSetter.Read();
}

  • 機能毎に3つのinterfaceが用意されており、必要なinterfaceのみを注入することでモジュールやオブジェクトの責務を明確にする。
  • VariableはStateVariableの略であり、StateVariableには「とあるContext内で共有する状態変数」という意味合いを込めている。そのため、型シグネチャによって共有されている変数ということを強調できる。
  • DependencyVariableにより、状態変数から導出される変数を状態変数と同じシグネチャでハンドリングできる

Installation ☘️

Install via git URL

  1. Open the Package Manager
  2. Press [+▼] button and click Add package from git URL...
  3. Enter the following:

Install via OpenUPM (not yet)

openupm add com.tanitaka-tech.state-variable

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 72 11/3/2024
1.2.4 127 9/3/2024