Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaslevesque authored Nov 24, 2019
1 parent 98bed95 commit b34ba27
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ private void OnMyEvent(MyEventArgs e)
That's it, you have a weak event! Client code can subscribe to it as usual, this is completely transparent from the subscriber's
point of view.

### Special case: anonymous method handlers

If you're subscribing to the event with an anonymous method (e.g. a lambda expression), make sure to keep a reference to the handler, otherwise it will be collected too soon. Alternatively, you can use the overload of `Subscribe` that accepts a lifetime object; this will cause the handler to stay alive as long as the lifetime object is alive (of course, in this case you can't use the event syntax; the event publisher will need to expose a specific method).

## How does it work

A delegate is made of two things:
Expand Down Expand Up @@ -77,4 +81,4 @@ we check if the target is still alive, and if it is, we invoke the open-instance

The package logo is made from two icons:
- [Lightning bolt](https://www.iconfinder.com/icons/2682840) by Laura Reen from Iconfinder, under license [CC BY-NC 3.0](https://creativecommons.org/licenses/by-nc/3.0/)
- [Broken link](https://thenounproject.com/term/broken-link/900264/) by Tomas Knopp from the Noun Project, under license [CC BY 3.0](https://creativecommons.org/licenses/by/3.0/)
- [Broken link](https://thenounproject.com/term/broken-link/900264/) by Tomas Knopp from the Noun Project, under license [CC BY 3.0](https://creativecommons.org/licenses/by/3.0/)

0 comments on commit b34ba27

Please sign in to comment.