Skip to content

grahamburgsma/events

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Events

Events provides a simple observer pattern to subscribe and listen for events in your Vapor application. This idea is based on Laravel Events.

Registering Events & Listeners

// Event
struct ThingHappened: Event { ... }

// Listeners
struct NofifyThing: Listener { ... }
struct SendEmailAboutThing: Listener { ... }

app.events.register(
    ThingHappened.self, 
    listeners: [
        NotifyThing.self, 
        SendEmailAboutThing.self
    ]
)

Emitting Events

let event = ThingHappened()
req.events.emit(event)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages