Skip to content

Commit 4658bb9

Browse files
committed
api/event: Describe stream events.
1 parent 979d283 commit 4658bb9

File tree

2 files changed

+24
-35
lines changed

2 files changed

+24
-35
lines changed

src/actionTypes.js

+2-34
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ import {
6666
EVENT,
6767
} from './actionConstants';
6868

69-
import { EventTypes } from './api/eventTypes';
70-
import type { MessageEvent, PresenceEvent } from './api/eventTypes';
69+
import type { MessageEvent, PresenceEvent, StreamEvent } from './api/eventTypes';
7170

7271
import type {
7372
Dimensions,
@@ -304,40 +303,9 @@ type EventSubscriptionPeerRemoveAction = {|
304303
user_id: number,
305304
|};
306305

307-
type EventStreamCreate = {|
308-
...ServerEvent,
309-
type: typeof EventTypes.stream,
310-
op: 'create',
311-
streams: Stream[],
312-
|};
313-
314-
type EventStreamDelete = {|
315-
...ServerEvent,
316-
type: typeof EventTypes.stream,
317-
op: 'delete',
318-
streams: Stream[],
319-
|};
320-
321-
type EventStreamUpdate = {|
322-
...ServerEvent,
323-
type: typeof EventTypes.stream,
324-
op: 'update',
325-
stream_id: number,
326-
name: string,
327-
property: string,
328-
value: string,
329-
|};
330-
331-
type EventStreamOccupy = {|
332-
...ServerEvent,
333-
type: typeof EventTypes.stream,
334-
op: 'occupy',
335-
streams: Stream[],
336-
|};
337-
338306
type GenericEventAction = {|
339307
type: typeof EVENT,
340-
event: EventStreamCreate | EventStreamDelete | EventStreamUpdate | EventStreamOccupy,
308+
event: StreamEvent,
341309
|};
342310

343311
type EventNewMessageAction = {|

src/api/eventTypes.js

+22-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* @flow strict-local
1111
*/
1212

13-
import type { Message } from './apiTypes';
13+
import type { Message, Stream } from './apiTypes';
1414

1515
//
1616
// First, types used inside events.
@@ -110,6 +110,27 @@ export type PresenceEvent = {|
110110
presence: UserPresence,
111111
|};
112112

113+
type StreamListEvent = {|
114+
...EventCommon,
115+
type: typeof EventTypes.stream,
116+
streams: Stream[],
117+
|};
118+
119+
// prettier-ignore
120+
export type StreamEvent =
121+
| {| ...StreamListEvent, op: 'create', |}
122+
| {| ...StreamListEvent, op: 'delete', |}
123+
| {| ...StreamListEvent, op: 'occupy', |}
124+
| {|
125+
...EventCommon,
126+
type: typeof EventTypes.stream,
127+
op: 'update',
128+
stream_id: number,
129+
name: string,
130+
property: string,
131+
value: string,
132+
|};
133+
113134
export type UpdateMessageFlagsEvent = {|
114135
...EventCommon,
115136
type: typeof EventTypes.update_message_flags,

0 commit comments

Comments
 (0)