heyitsmass / BayView

The next generation reservation tracking and notification system
https://bayview.dev
MIT License
1 stars 2 forks source link

EventManager Implementation #25

Closed heyitsmass closed 11 months ago

heyitsmass commented 1 year ago

The event manager is the core to the itinerary manager and functions as a unique context manager an Itinerary/Group.

This can be converted to an abstract class and it's methods can be utilized in other classes that need a context manager

state is the current event states is the list of events (in order) in the itinerary $history is the history of the state, each time a transition happens the previous state is pushed into the history transition_to_next_event() pops the next event off the stack and transitions the internal state to it switch_to_event(state:Event) transitions the internal state to a specific event -> the event must be in the users current list of events transition_to_previous_event()pops the last event off of the history and transitions to it

A simple diagram of how this could work:

User has an itinerary -> attaches a notifier -> notifier notifies the user -> The itinerary observers this notification -> The itinerary transitions to the next event observed by the notifier

https://github.com/heyitsmass/BayView/blob/b335f46bd55299100313360e111e700b8bc3f6a0/src/types/ItineraryManager.ts#L120-L147