Merge PR #5583: Add to the docs of events and handler to set a new EventManager to the Context

This commit is contained in:
Nicolas Mahé
2020-01-29 08:43:48 -05:00
committed by GitHub
parent ec35cf2d91
commit ca952bc9c6
2 changed files with 11 additions and 1 deletions
+8
View File
@@ -61,6 +61,14 @@ ctx.EventManager().EmitEvent(
)
```
Module's `handler` function should also set a new `EventManager` to the `context` to isolate emitted events per `message`:
```go
func NewHandler(keeper Keeper) sdk.Handler {
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
ctx = ctx.WithEventManager(sdk.NewEventManager())
switch msg := msg.(type) {
```
See the [`Handler`](../building-modules/handler.md) concept doc for a more detailed
view on how to typically implement `Events` and use the `EventManager` in modules.