Created
November 10, 2022 11:58
-
-
Save saitocastel1900/f07c961791e58e758a30238f9098b6c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UniRx; | |
using UnityEngine; | |
namespace Gauge | |
{ | |
public class Presenter : MonoBehaviour | |
{ | |
//view | |
[SerializeField] private View _view; | |
//model | |
private Model _model; | |
private void Start() | |
{ | |
_model = new Model(0); | |
_view.Initialized(); | |
Bind(); | |
SetEvent(); | |
} | |
private void Bind() | |
{ | |
//view=>model | |
_view.ObservableClickButton() | |
.Select(_ => +1) | |
.Subscribe( | |
value => _model.UpdateCount(_model.Value.Value + (int) value), | |
ex => Debug.LogError("OnError!"), | |
() => Debug.Log("")).AddTo(this); | |
//model=>view | |
_model.Value | |
.Subscribe(x => | |
{ | |
_view.UpdateText(x); | |
_view.GaugeValue = x; | |
_view.GaugeAnimation(); | |
}, | |
ex => Debug.LogError("OnError!"), | |
() => Debug.Log("OnCompleted!")).AddTo(this); | |
} | |
private void SetEvent() | |
{ | |
_model.OnCallback += _view.UnInteractiveClick; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment