Documentation Index
Fetch the complete documentation index at: https://docs.skyvexsoftware.com/llms.txt
Use this file to discover all available pages before exploring further.
useFlightEvents provides access to the live flight event log. It hydrates from GET /api/flight-events on mount, then subscribes to flight:event Socket.io events to append new events as they arrive. Comment mutations (add, edit, delete) use optimistic updates.
Import
import { useFlightEvents } from "@skyvexsoftware/stratos-sdk";
Signature
function useFlightEvents(
options?: UseFlightEventsOptions
): UseFlightEventsReturn
type UseFlightEventsOptions = {
flightId?: string | number | null;
categories?: EventCategory[];
};
type UseFlightEventsReturn = {
events: FlightLogEvent[];
isTracking: boolean;
isLoading: boolean;
addComment: (message: string) => void;
editComment: (id: string, message: string) => void;
deleteComment: (id: string) => void;
};
Parameters
| Parameter | Type | Description |
|---|
options.flightId | string | number | null | Filter events to a specific flight. Defaults to the current active flight. |
options.categories | EventCategory[] | Filter events by category. If omitted, all categories are returned. |
Return value
| Field | Type | Description |
|---|
events | FlightLogEvent[] | Ordered array of flight events (filtered if categories was provided) |
isTracking | boolean | Whether a flight is currently active |
isLoading | boolean | True during the initial REST fetch |
addComment | (message: string) => void | Add a pilot comment event to the current flight |
editComment | (id: string, message: string) => void | Edit an existing comment (optimistic update) |
deleteComment | (id: string) => void | Delete a comment (optimistic update) |
FlightLogEvent
type FlightLogEvent = {
eventId: string;
eventTimestamp: string; // ISO 8601 timestamp
eventElapsedTime: number; // milliseconds since flight start
eventCondition: string; // rule name or trigger identifier
category: EventCategory;
message: string;
data?: Record<string, unknown>;
};
EventCategory enum
enum EventCategory {
SYSTEM = "system", // Simulator connection, tracking start/end
PHASE = "phase", // Flight phase transitions
CONTROLS = "controls", // Gear, flaps, reverser events
ENGINE = "engine", // Engine start/stop events
WARNING = "warning", // Stall, overspeed, crash detection
POSITION = "position", // Position-related events
COMMENT = "comment", // Pilot comments
}
Usage
import { useFlightEvents } from "@skyvexsoftware/stratos-sdk";
export function EventLog() {
const { events, isLoading, addComment } = useFlightEvents();
if (isLoading) return <p>Loading events...</p>;
return (
<div>
<ul>
{events.map((event) => (
<li key={event.eventId}>
[{event.category}] {event.message}
</li>
))}
</ul>
<button onClick={() => addComment("Cruising at FL350")}>
Add Comment
</button>
</div>
);
}
Filtering by category
import { useFlightEvents, EventCategory } from "@skyvexsoftware/stratos-sdk";
// Show only phase transitions and warnings
const { events } = useFlightEvents({
categories: [EventCategory.PHASE, EventCategory.WARNING],
});
const { events, editComment, deleteComment } = useFlightEvents();
const commentEvents = events.filter((e) => e.category === EventCategory.COMMENT);
commentEvents.forEach((event) => {
// Edit: fires a PUT to /api/flight-events/comments/:id with optimistic update
editComment(event.eventId, "Updated message");
// Delete: fires a DELETE to /api/flight-events/comments/:id with optimistic removal
deleteComment(event.eventId);
});
Notes
- New events arriving via Socket.io are appended to the end of the
events array without invalidating or refetching the full query.
addComment does not use an optimistic update — the new comment event arrives via the flight:event Socket.io broadcast and is appended automatically.
editComment and deleteComment apply optimistic updates immediately and roll back on API error.
- The
staleTime: Infinity setting means events are never automatically re-fetched in the background.