Skip to content

Commit

Permalink
Merge pull request #32 from LibraStack/develop
Browse files Browse the repository at this point in the history
Minor changes.
  • Loading branch information
ChebanovDD authored Jun 15, 2023
2 parents dacb116 + e6f0159 commit d50d1f2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,22 @@ namespace UnityMvvmToolkit.Common
public abstract class MonoBehaviourView<TBindingContext> : MonoBehaviour, IBindableElement
where TBindingContext : class, IBindingContext
{
private TBindingContext _createdBindingContext;
private bool _isInitialized;

private TBindingContext _bindingContext;
private IObjectProvider _objectProvider;

private TBindingContext _createdBindingContext;

protected virtual bool InitOnAwake => true;
public TBindingContext BindingContext => _bindingContext;

private void Awake()
{
OnInit();
SetBindingContext();
if (InitOnAwake)
{
Init();
}
}

private void OnDestroy()
Expand All @@ -34,6 +39,19 @@ private void OnDestroy()
OnDispose();
}

protected void Init()
{
if (_isInitialized)
{
throw new InvalidOperationException($"{GetType().Name} already initialized.");
}

OnInit();
SetBindingContext();

_isInitialized = true;
}

public void SetBindingContext(IBindingContext context, IObjectProvider objectProvider)
{
if (_bindingContext is not null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.chebanovdd.unitymvvmtoolkit",
"displayName": "Unity MVVM Toolkit",
"author": { "name": "ChebanovDD", "url": "https://github.com/ChebanovDD" },
"version": "1.1.3",
"version": "1.1.4",
"unity": "2018.4",
"description": "The Unity Mvvm Toolkit allows you to use data binding to establish a connection between the app UI and the data it displays. This is a simple and consistent way to achieve clean separation of business logic from UI.",
"keywords": [ "mvvm", "binding", "ui", "toolkit" ],
Expand Down
4 changes: 2 additions & 2 deletions src/UnityMvvmToolkit.UnityPackage/Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"dependencies": {
"com.cysharp.unitask": "2.3.3",
"com.unity.collab-proxy": "2.0.4",
"com.unity.collab-proxy": "2.0.5",
"com.unity.feature.2d": "1.0.0",
"com.unity.ide.rider": "3.0.22",
"com.unity.ide.rider": "3.0.24",
"com.unity.ide.visualstudio": "2.0.18",
"com.unity.ide.vscode": "1.2.5",
"com.unity.test-framework": "1.1.33",
Expand Down
4 changes: 2 additions & 2 deletions src/UnityMvvmToolkit.UnityPackage/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"url": "https://packages.unity.com"
},
"com.unity.collab-proxy": {
"version": "2.0.4",
"version": "2.0.5",
"depth": 0,
"source": "registry",
"dependencies": {},
Expand Down Expand Up @@ -130,7 +130,7 @@
}
},
"com.unity.ide.rider": {
"version": "3.0.22",
"version": "3.0.24",
"depth": 0,
"source": "registry",
"dependencies": {
Expand Down

0 comments on commit d50d1f2

Please sign in to comment.