Skip to content

Listener #29

Closed Answered by GregoryConrad
busslina asked this question in Q&A
Dec 23, 2023 · 5 comments · 6 replies
Discussion options

You must be logged in to vote

I'm going to try to answer all of your questions/comments here:

Firstly, can you explain why use.asListener() is needed and how it works?

Here's why it is needed. Take the following:

int xCapsule(CapsuleHandle use) => /* impl hidden */;
void xLoggerCapsule(CapsuleHandle use) => print(use(xCapsule));

If we read xLoggerCapsule from the container once (so the container knows of its existence), we may then expect for it to log all future values of xCapsule. Here's the catch: it won't. As soon as xCapsule changes, the container will recognize that its only dependents have no "demand" (i.e., nothing downstream registers a side effect), and will garbage collect the xLoggerCapsule without it ev…

Replies: 5 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@busslina
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

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

@busslina
Comment options

Answer selected by GregoryConrad
Comment options

You must be logged in to vote
3 replies
@busslina
Comment options

@GregoryConrad
Comment options

@busslina
Comment options

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