Skip to content

Commit 8262eaf

Browse files
committed
Updated readme
1 parent 741d2c4 commit 8262eaf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,23 @@ private void InvokeEvent()
127127
}
128128
```
129129

130+
### Exposing
131+
132+
Now that you've set up your Safe Event you most likely want to be able to use it from a different place.
133+
134+
The recommended way of doing this is by exposing an event property as shown below, instead of directly exposing the Safe Event
135+
136+
```c#
137+
private SafeEvent<int> onFooEvent;
138+
139+
public event Action<int> OnFooEvent
140+
{
141+
add => onFooEvent.Subscribe(value);
142+
remove => onFooEvent.Unsubscribe(value);
143+
}
144+
```
145+
146+
The benefit of this is that to the outside it looks and behaves like a normal event even though under the hood it has the benefits of the Safe Event.
130147

131148
## Support
132149
**Safe Event** is a small and open-source utility that I hope helps other people. It is by no means necessary but if you feel generous you can support me by donating.

0 commit comments

Comments
 (0)