struct EE::ObservableValue::State

struct State {
    // typedefs

    typedef std::function<void(const T&)> Callback;
    typedef SmallVector<Observer, 4> Observers;

    // structs

    struct Observer;

    // fields

    T value;
    Uint32 nextId { 0 };
    Observers observers;
    Observers pendingObservers;
    std::optional<T> pendingValue;
    bool notifying { false };
    static constexpr Uint32 MaxReentrantNotifications = 1024;

    // construction

    State(T value);

    // methods

    void set(const T& newValue);
    void set(T&& newValue);

    template <typename U>
    void setImpl(U&& newValue);

    Observers::iterator find(Uint32 id);
    Observers::const_iterator find(Uint32 id) const;
    bool contains(Uint32 id) const;
    void remove(Uint32 id);
    void add(Uint32 id, Callback callback);
};