actions.ts 728 B

12345678910111213141516171819202122232425
  1. import { MusicPlayer } from '../types/state';
  2. interface Action<T extends string = string, P = unknown> {
  3. type: T;
  4. payload: P;
  5. }
  6. export enum ActionTypeRemote {
  7. StateSet = 'STATE_SET',
  8. ClientsUpdated = 'CLIENTS_UPDATED',
  9. }
  10. export enum ActionTypeLocal {
  11. StateSet = 'LOCAL_STATE_SET',
  12. }
  13. export type ActionStateSetRemote = Action<ActionTypeRemote.StateSet, MusicPlayer | null>;
  14. export type ActionStateSetLocal = Action<ActionTypeLocal.StateSet, MusicPlayer>;
  15. export type ActionClientsUpdated = Action<ActionTypeRemote.ClientsUpdated, string[]>;
  16. export type LocalAction = ActionStateSetLocal;
  17. export type RemoteAction = ActionStateSetRemote | ActionClientsUpdated;
  18. export type AnyAction = LocalAction | RemoteAction;