1.0.0 • Published 7 months ago

event-sorter v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

event-sorter

Simple event sorter that ensures the correct order of events.

enum EventId {
  First = 1,
  Second = 2,
  Third = 3,
  Fourth = 4,
}

const requiredOrderOfEvents = [
  EventId.First,
  EventId.Second,
  EventId.Third,
  EventId.Fourth,
];

const eventSorter = new EventSorter<EventId>(requiredOrderOfEvents);

eventSorter.scheduleInitialEvent(EventId.First, () =>
  console.log("first event");
);
eventSorter.scheduleInitialEvent(EventId.Fourth, () =>
  console.log("fourth event");
);
eventSorter.scheduleInitialEvent(EventId.Third, () =>
  console.log("third event");
);
eventSorter.scheduleInitialEvent(EventId.Second, () =>
  console.log("second event");
);
1.0.0

7 months ago

0.0.1

7 months ago