While working on one of my inspirational open-source projects, I found out that there's currently no way to observe element style changes. At least I couldn't find any mentions of library-like solutions for that. I assume that the reason for that might be the fact it's hard to understand whether or not the styles have changed.
I recently joined a developer community Dev.to. It is a really nice place where people spur discussions and ask questions that are not only related to technologies and software development but are incredibly important as well, for us, the human beings constantly looking for meaning in life. One of these questions is my favorite “What are your career goals?”.
There is a widely held opinion, which I usually support, that declarative code is "better" than imperative. It is less error-prone, usually much more eloquent and neat, and hence more maintainable. It is a good principle to follow on a day-to-day basis when you use existing declarative tools or libraries, like JS standard
Array methods, or
lodash, or React.
However, when it comes to deciding to either write some declarative, and therefore more generalized code, or just leave an imperative solution, I suggest thinking at least twice.
Imagine you’re writing an algorithm that performs looping over an array with any type of pointer (
map, etc). Each iteration the pointer moves in any direction, but you never force it to come back in most cases. Why should you, after all?
This mode of manipulating data is so usual that you probably have never thought about how liable it is to causing hard-to-find bugs, which lead you towards tiresome debugging!