Skip to content

How to add all-capsules/container listener or observer for logging #107

Closed Answered by GregoryConrad
Kypsis asked this question in Q&A
Discussion options

You must be logged in to vote

@Kypsis Yea, I never got around to actually finishing that page. Maybe I can tackle it this evening.

The idea is to just create a new capsule and opt-in to the capsules you want to listen to, knowing that they will never be freed from the container when you use listeners. Normally, ReArch will garbage-collect any capsules that don't use side effects when their dependencies change, but if you are adding a listener to those capsules, then they won't be freed. This doesn't matter at all if you are listening to a stateful capsule, but it can matter if you have a series of capsules that just do some simple data transformations that should be freed when no longer in use.

Here's a quick example:

(

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@GregoryConrad
Comment options

@Kypsis
Comment options

@GregoryConrad
Comment options

@Kypsis
Comment options

Answer selected by Kypsis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants