We’re rewarding the question askers & reputations are being recalculated! Read more.

New answers tagged

2

I am especially unsure about looping over the sections in a scroll event. There doesn't seem to be much of an alternative. One could select all elements with class name is-visible: const visible = document.getElementsByClassName('is-visible'); Note that that collection is live, meaning it will be updated dynamically as the DOM changes, so there isn't any ...


1

Find the differences and extract them into separate functions that you can pass as a parameter to the common processing function Use modern syntax: async/await, fetch, for-of, destructuring assignment const wrapper = document.querySelector('.wrapper'); const fieldDefinitions = { '.test': { Name: person => person.name.first, }, '.testLastName': {...


2

Don't know if you dislike "not this-lang-onian" comments... typedef std::function<void(Event&)> EventHandler; should be using EventHandler = std::function<void(Event&)>; auto get_event_type() -> std::type_index { return std::type_index(typeid(T)); } you already have type in return statement, no need for trailing return type ...


2

Summary Feel free to ignore opinion: Personal opinion I don't like "Snake Case" and I don't see it very often in C++ projects (though an argument against me is the C++ standard library does use it). I also prefer not to use "m_" to identify member variables. It tends to mean that people have not though enough about unique meaningful names elsewhere and ...


2

template <typename EventType> Message(EventType &&event, EventHandler event_handler): m_event(std::make_unique<EventType>(std::move(event))), m_event_handler(event_handler) {} Requiring an r-value event seems unnecessary here; we should probably take it by value. template <typename EventType> Message(Message&& ...


Top 50 recent answers are included