2 ms·
There's something to be said for globals whose access is well-managed, though. IMO: if the variable is _truly_ global, i.e. code all over the codebase cares ab
by ajkjk 3y ago
There's something to be said for globals whose access is well-managed, though.
IMO: if the variable is _truly_ global, i.e. code all over the codebase cares about it, then it should just be global instead of pretending like it's not with some fancy architecture.
The tricky part is reacting to changes to a global variable. Writing a bunch of "on update" logic leads to madness. The ideal solution is for there to be some sort of one-directional flow for updates, like when a React component tree is re-rendered... but that's very hard to build in an application that doesn't start out using a library like React in the first place.