Immutable capsules usage #44
-
Is okay for a capsule that I know will not change, to use Is this way more efficient because it doesn't register any logic for that capsule? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Where would you call this container.read? If the answer is from within a capsule or RearchConsumer (which will be 99.99% of the time unless you’re making a web server), then no, do not use container.read. The overhead of In capsules/RearchConsumer, always |
Beta Was this translation helpful? Give feedback.
Where would you call this container.read? If the answer is from within a capsule or RearchConsumer (which will be 99.99% of the time unless you’re making a web server), then no, do not use container.read.
The overhead of
use(someCapsule)
is negligible and when dependencies are cached it is O(1) (at least in the dart implementation, in Rust it’s O(logn) iirc because of the concurrency model).In capsules/RearchConsumer, always
use(someCapsule)
. It will ensure you don’t shoot yourself in the foot when things change in the future.