[core] settings: Callback bindings #3523

Open
opened 2026-02-11 15:53:22 +01:00 by crueter · 0 comments
Owner

Issue

One of the greater annoyances of the settings API is the total lack of callbacks. You have to manually update the setting every single time.

A theoretical callback API could be something as simple as storing a std::function consumer within the Setting class and calling it every time the value changes. These could be registered with e.g.

void Setting::RegisterCallback(std::function<void(const Type&)> &func) {
    this->callback = func;
    func(GetValue());
}

// ...

void SetValue(const Type& val) override final {
    Type temp{ranged ? std::clamp(val, this->minimum, this->maximum) : val};
    if (use_global) {
        std::swap(this->value, temp);
    } else {
        std::swap(custom, temp);
    }

    this->callback(temp);
}
### Issue One of the greater annoyances of the settings API is the total lack of callbacks. You have to manually update the setting every single time. A theoretical callback API could be something as simple as storing a `std::function` consumer within the Setting class and calling it every time the value changes. These could be registered with e.g. ```cpp void Setting::RegisterCallback(std::function<void(const Type&)> &func) { this->callback = func; func(GetValue()); } // ... void SetValue(const Type& val) override final { Type temp{ranged ? std::clamp(val, this->minimum, this->maximum) : val}; if (use_global) { std::swap(this->value, temp); } else { std::swap(custom, temp); } this->callback(temp); } ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
eden-emu/eden#3523
No description provided.