57 _value_cbt = _value.subscribe([
this](
auto...) {
58 if (
auto tmp = this->encode(); not holds_alternative<std::monostate>(tmp)) {
59 this->_parent.write(_path, this->encode());
61 this->_parent.remove(_path);
72 [[nodiscard]]
datum encode() const noexcept
override
74 if (*_value != _init) {
75 return hi::pickle<T>{}.encode(*_value);
77 return datum{std::monostate{}};
81 void decode(datum
const &data)
override
83 _value = hi::pickle<T>{}.decode(data);
89 typename decltype(_value)::token_type _value_cbt;
146 void save() const noexcept;
154 void save(
URL location) noexcept;
160 void load() noexcept;
168 void load(
URL location) noexcept;
172 void reset() noexcept;
181 void add(
std::string_view path,
observable<T> const &item, T init = T{})
noexcept
183 auto item_ = std::make_unique<detail::preference_item<T>>(*
this, path, item,
std::move(init));
200 mutable bool _modified =
false;
202 loop::timer_token_type _check_modified_cbt;
208 void _load() noexcept;
209 void _save() const noexcept;
213 void check_modified() noexcept;
217 void write(jsonpath const &path, datum const value) noexcept;
221 datum read(jsonpath const &path) noexcept;
225 void remove(jsonpath const &path) noexcept;
227 friend class detail::preference_item_base;
229 friend class detail::preference_item;