Last active
November 11, 2022 09:16
-
-
Save saitocastel1900/3fb23edd27d08e8b695cd66e11b7963f 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 System; | |
using UniRx; | |
using UnityEngine; | |
namespace Gauge | |
{ | |
public class Presenter : IDisposable | |
{ | |
//view | |
private View _view; | |
//model | |
private Model _model; | |
CompositeDisposable disposables = new CompositeDisposable(); | |
public Presenter(Model model, View view) | |
{ | |
Debug.Log("コンストラクタ発動"); | |
_model = model; | |
_view = view; | |
_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(disposables); | |
//model=>view | |
_model.Value | |
.Subscribe(x => | |
{ | |
_view.UpdateText(x); | |
_view.GaugeValue = x; | |
_view.GaugeAnimation(); | |
}, | |
ex => Debug.LogError("OnError!"), | |
() => Debug.Log("OnCompleted!")).AddTo(disposables); | |
} | |
private void SetEvent() | |
{ | |
_model.OnCallback += _view.UnInteractiveClick; | |
} | |
public void Dispose() | |
{ | |
disposables.Dispose(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment