EventsExamples

Event Examples

From the Concert App tutorial.


Follow graph

# events/follow.events.causet
events:
  ARTIST_FOLLOWED:
    state: user
    entity_expr: event.user_id
    payload:
      user_id:   string
      artist_id: string
 
  ARTIST_UNFOLLOWED:
    state: user
    entity_expr: event.user_id
    payload:
      user_id:   string
      artist_id: string

Shows and attendance

events:
  SHOW_ANNOUNCED:
    state: artist
    entity_expr: event.artist_id
    payload:
      artist_id:    string
      show_id:      string
      venue_id:     string
      title:        string
      date:         string
 
  USER_MARKED_GOING:
    state: user
    entity_expr: event.user_id
    payload:
      user_id: string
      show_id: string
 
  USER_CHECKED_IN:
    state: user
    entity_expr: event.user_id
    payload:
      user_id:   string
      show_id:   string
      artist_id: string
      venue_id:  string
 
  CONCERT_MEMORY_CREATED:
    state: user
    entity_expr: event.user_id
    payload:
      user_id:    string
      show_id:    string
      artist_id:  string
      venue_id:   string
      checked_in: boolean

Design note: CHECK_IN emits both USER_CHECKED_IN (attendance counters) and CONCERT_MEMORY_CREATED (user memory projection) — different projections listen to different facts.


Reviews

events:
  REVIEW_SUBMITTED:
    state: user
    entity_expr: event.user_id
    payload:
      user_id:   string
      show_id:   string
      artist_id: string
      rating:    int
      notes:     string

System event

events:
  PROJECTION_FAILED:
    state: _system
    kind: system
    entity_expr: event.entity_id
    payload:
      projection_name: string
      error:           string

More examples

ExampleEvents demonstrated
Concert AppFull event catalog with actions
Defining EventsPayload types and kind
Dispatching Eventsop: emit from rules

Next steps