

namespace Stary.Evo.Example.Counter
{

    public interface ICounterData : IData
    {
        BindableProperty<int> Count { get; }
    }

    public class CounterData : AbstractData, ICounterData
    {
        public override void Dispose()
        {
            
        }

        protected override void OnInit()
        {
            var storage = this.GetUtility<IStorage>();
            Count.Value = storage.LoadInt("COUNTER_COUNT", 0);

            Count.Register( count => { storage.SaveInt("COUNTER_COUNT", count); });
        }

        public BindableProperty<int> Count { get; } = new BindableProperty<int>()
        {
            Value = 0
        };
        
    }
}