blob: c3c61c1ff8b6ab45e20657d9328b9a29f02c5892 [file] [log] [blame]
Hector Dearman916c7612018-07-09 15:42:22 +01001// Copyright (C) 2018 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Deepanjan Roy75b46a92018-07-24 09:11:29 -040015/**
16 * A plain js object, holding objects of type |Class| keyed by string id.
17 * We use this instead of using |Map| object since it is simpler and faster to
18 * serialize for use in postMessage.
19 */
20export interface ObjectById<Class extends{id: string}> { [id: string]: Class; }
21
22export interface State {
23 i: number;
24 tracks: ObjectById<TrackState>;
25}
26
27export interface TrackState {
28 id: string;
29 type: string;
30 height: number;
31 name: string;
32}
Hector Dearman916c7612018-07-09 15:42:22 +010033
34export function createEmptyState(): State {
35 return {
36 i: 0,
Deepanjan Roy75b46a92018-07-24 09:11:29 -040037 tracks: {},
Hector Dearman916c7612018-07-09 15:42:22 +010038 };
39}