types.ts 756 B

1234567891011121314151617181920212223242526
  1. // Remote actions - these only come FROM the socket
  2. export enum ActionTypeRemote {
  3. StateSet = 'STATE_SET',
  4. ClientListUpdated = 'CLIENT_LIST_UPDATED',
  5. }
  6. // Local actions - these are dispatched from this client
  7. export enum ActionTypeLocal {
  8. ErrorOccurred = '@@local/ERROR_OCCURRED',
  9. NameSet = '@@local/NAME_SET',
  10. StateSet = '@@local/STATE_SET',
  11. Seeked = '@@local/SEEKED',
  12. MasterRetaken = '@@local/MASTER_RETAKEN',
  13. }
  14. interface Action<T extends string = string, P = unknown> {
  15. type: T;
  16. payload: P;
  17. }
  18. export type ActionRemote<T extends ActionTypeRemote = ActionTypeRemote, P = unknown> = Action<
  19. T,
  20. P
  21. > & { fromClient?: string | null };
  22. export type ActionLocal<T extends ActionTypeLocal = ActionTypeLocal, P = unknown> = Action<T, P>;