jamesmontemagno / SettingsPlugin

Read and Write Settings Plugin for Xamarin and Windows
MIT License
324 stars 80 forks source link

async? #118

Closed tofutim closed 6 years ago

tofutim commented 6 years ago

Since SettingsPlugin depends on writing to disk, do you think there would be value to async especially as the number of settings increases? I find myself often doing things like this

        public bool IsShowHSK
        {
            get => AppSettings.GetValueOrDefault(nameof(IsShowHSK), true);
            set
            {
                if (IsShowHSK == value) return;
                AppSettings.AddOrUpdateValue(nameof(IsShowHSK), value);
                RaisePropertyChanged(() => IsShowHSK);
            }
        }

and I wonder if it would be better to pre-set _isShowHSK from app settings so that instead I have

        private bool _isShowHSK = AppSettings.GetValueOrDefault(nameof(IsShowHSK), true);
        public bool IsShowHSK
        {
            get => _isShowHSK
            set
            {
                if (IsShowHSK == value) return;
                RaisePropertyChanged(() => IsShowHSK);
                AppSettings.AddOrUpdateValueAsyncFireAndForget(nameof(IsShowHSK), value);
            }
        }
jamesmontemagno commented 6 years ago

It is not needed as each platform handle it automatically by batching and never takes more time then necessary for it to be async.