An open API service indexing awesome lists of open source software.

https://github.com/liangxiegame/uiwidgetsreduxpersist

Saver Middle Ware 4 UIWidgets Redux
https://github.com/liangxiegame/uiwidgetsreduxpersist

u3d uiwidgets unity unity3d

Last synced: 6 months ago
JSON representation

Saver Middle Ware 4 UIWidgets Redux

Awesome Lists containing this project

README

          

# UIWidgetsReduxPersist
Saver Middle Ware 4 UIWidgets Redux

### Example:

``` csharp
using System.Collections.Generic;
using Unity.UIWidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.material;
using Unity.UIWidgets.Redux;
using Unity.UIWidgets.widgets;
// 1.import namespace
using QFramework.UIWidgets.ReduxPersist;

namespace QF.UIWidgets.ReduxPersist.Example
{
// 2.declare state
class ExampleState : AbstractPersistState
{
public int Count = 0;
}

public class Example : UIWidgetsPanel
{
protected override Widget createWidget()
{
var store = new Store((state, action) =>
{
switch (action)
{
case IncreaseCountAction _:
return new ExampleState
{
Count = state.Count + 1
};

case DecreaseCountAction _:
return new ExampleState
{
Count = state.Count - 1
};
}

return state;
},
// 3.call load
ExampleState.Load(),
// 4.add middleware
ReduxPersistMiddleware.create());
return new StoreProvider(store,
child: new StoreConnector(
converter: state => state.Count,
builder: (context, model, dispatcher) =>
{
return new Row(
children: new List()
{
new FlatButton(
child: new Text("-"),
onPressed: () => { dispatcher.dispatch(new DecreaseCountAction()); }
),
new Text(model.ToString()),
new FlatButton(
child: new Text("+"),
onPressed: () => { dispatcher.dispatch(new IncreaseCountAction()); }
),
}
);
}
)
);
}
}

class IncreaseCountAction
{

}

class DecreaseCountAction
{

}
}

```

### Dependenciy:

* [JSON.NET for Unity](https://assetstore.unity.com/packages/tools/input-management/json-net-for-unity-11347)
* [UIWidgets](https://github.com/UnityTech/UIWidgets)