-
Notifications
You must be signed in to change notification settings - Fork 2
/
menu-data.service-model.ts
113 lines (109 loc) · 3.88 KB
/
menu-data.service-model.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import {
OnDidDispose,
UnsubscriberAsync,
MultiColumnMenu,
ReferencedItem,
WebViewMenu,
} from 'platform-bible-utils';
import {
DataProviderDataType,
DataProviderSubscriberOptions,
DataProviderUpdateInstructions,
} from '@shared/models/data-provider.model';
import { IDataProvider } from './papi-core.service';
/** JSDOC DESTINATION menuDataServiceProviderName */
export const menuDataServiceProviderName = 'platform.menuDataServiceDataProvider';
export const menuDataServiceObjectToProxy = Object.freeze({
/**
* JSDOC SOURCE menuDataServiceProviderName
*
* This name is used to register the menu data data provider on the papi. You can use this name to
* find the data provider when accessing it using the useData hook
*/
dataProviderName: menuDataServiceProviderName,
});
// Data Type to initialize data provider engine with
export type MenuDataDataTypes = {
MainMenu: DataProviderDataType<undefined, MultiColumnMenu, never>;
WebViewMenu: DataProviderDataType<ReferencedItem, WebViewMenu, never>;
};
declare module 'papi-shared-types' {
export interface DataProviders {
[menuDataServiceProviderName]: IMenuDataService;
}
}
/**
* JSDOC SOURCE menuDataService
*
* Service that allows to get and store menu data
*/
export type IMenuDataService = {
/**
* JSDOC SOURCE getMainMenu
*
* Get menu content for the main menu
*
* @param mainMenuType Does not have to be defined
* @returns MultiColumnMenu object of main menu content
*/
getMainMenu(mainMenuType: undefined): Promise<MultiColumnMenu>;
/** JSDOC DESTINATION getMainMenu */
getMainMenu(): Promise<MultiColumnMenu>;
/**
* This data cannot be changed. Trying to use this setter this will always throw
*
* @param mainMenuType Does not have to be defined
* @param value MultiColumnMenu object to set as the main menu
* @returns Unsubscriber function
*/
setMainMenu(
mainMenuType: undefined,
value: never,
): Promise<DataProviderUpdateInstructions<MenuDataDataTypes>>;
/**
* Subscribe to run a callback function when the main menu data is changed
*
* @param mainMenuType Does not have to be defined
* @param callback Function to run with the updated menuContent for this selector
* @param options Various options to adjust how the subscriber emits updates
* @returns Unsubscriber function (run to unsubscribe from listening for updates)
*/
subscribeMainMenu(
mainMenuType: undefined,
callback: (menuContent: MultiColumnMenu) => void,
options?: DataProviderSubscriberOptions,
): Promise<UnsubscriberAsync>;
/**
* Get menu content for a web view
*
* @param webViewType The type of webview for which a menu should be retrieved
* @returns WebViewMenu object of web view menu content
*/
getWebViewMenu(webViewType: ReferencedItem): Promise<WebViewMenu>;
/**
* This data cannot be changed. Trying to use this setter this will always throw
*
* @param webViewType The type of webview for which a menu should be set
* @param value Menu of specified webViewType
* @returns Unsubscriber function
*/
setWebViewMenu(
webViewType: ReferencedItem,
value: never,
): Promise<DataProviderUpdateInstructions<MenuDataDataTypes>>;
/**
* Subscribe to run a callback function when the web view menu data is changed
*
* @param webViewType The type of webview for which a menu should be subscribed
* @param callback Function to run with the updated menuContent for this selector
* @param options Various options to adjust how the subscriber emits updates
* @returns Unsubscriber function (run to unsubscribe from listening for updates)
*/
subscribeWebViewMenu(
webViewType: ReferencedItem,
callback: (menuContent: WebViewMenu) => void,
options?: DataProviderSubscriberOptions,
): Promise<UnsubscriberAsync>;
} & OnDidDispose &
typeof menuDataServiceObjectToProxy &
IDataProvider<MenuDataDataTypes>;