Replies: 1 comment
-
I also strongly discourage IoC usage as a promo term or feature since it's a basic term used everywhere |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There's a design pattern called Inversion of Control. In general, it states that it's not you who call some functionality but something, namely framework or library, calls your code when something specific needs to be done. You delegate some functionality to some other code and handle its result later. The simplest example of IoC is Callback pattern that is widely used in Node.js and Listeners that are used by Web platform in general.
Dependency injection is a specific form of IoC that is used to compose complex things using simple ones. DI is used to delegate composition to someone. Many DI libraries employ interface/implementation segregation to replace one implementation with another without breaking the interface. Also, there are many features in contemporary DI libraries such as conditional resolution, scopes, and lifetime control.
Reatom uses IoC in these situations:
But reatom doesn't provide any functionality to compose atoms automatically. All atoms are explicitly composed by a developer using
ctx.spy(specificAtom)
andctx.get(specificAtom)
.Note: atom factories, such as reatomAsync, are examples of a producing pattern.
I propose replacing "Implicit DI for simple SSR and testing" with something else. SSR often involves IoC usage to unify the state among servers and browsers. Testing, mainly unit testing, does heavily encourage IoC to only test one unit at a time but still doesn't require DI to work.
Beta Was this translation helpful? Give feedback.
All reactions