Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
yohamta committed Nov 5, 2022
1 parent 3ebb353 commit c9b392a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,21 +455,23 @@ type EnemyKilled struct {
EnemyID int
}

world := donburi.NewWorld()

// Define an EventType with arbitrary number of subscribers
var EnemyKilledEvent = events.NewEventType()

// Add Handlers for the event
EnemyKilledEvent.Subscribe(w, LevelUp)
EnemyKilledEvent.Subscribe(w, UpdateScore)
EnemyKilledEvent.Subscribe(world, LevelUp)
EnemyKilledEvent.Subscribe(world, UpdateScore)

// Sending an Event
EnemyKilledEvent.Publish(world, EnemyKilled{EnemyID: 1})

// Process specific events
EnemyKilledEvent.ProcessEvents()
EnemyKilledEvent.ProcessEvents(world)

// Process all events
events.ProcessAllEvents(w)
events.ProcessAllEvents(world)

// Receives the events
func LevelUp(w donburi.World, event EnemyKilled) {
Expand Down

0 comments on commit c9b392a

Please sign in to comment.