(subscriptions: SubscriptionsRouter, editor: EditorWrapper, portfolio: PortfolioStore)
| 16 | let portfolioStore: PortfolioStore | undefined = undefined; |
| 17 | |
| 18 | export function createPersistenceManager(subscriptions: SubscriptionsRouter, editor: EditorWrapper, portfolio: PortfolioStore) { |
| 19 | destroyPersistenceManager(); |
| 20 | |
| 21 | subscriptionsRouter = subscriptions; |
| 22 | editorWrapper = editor; |
| 23 | portfolioStore = portfolio; |
| 24 | |
| 25 | subscriptions.subscribeFrontendMessage("TriggerSavePreferences", async (data) => { |
| 26 | await saveEditorPreferences(data.preferences); |
| 27 | }); |
| 28 | |
| 29 | subscriptions.subscribeFrontendMessage("TriggerLoadPreferences", async () => { |
| 30 | await loadEditorPreferences(editor); |
| 31 | }); |
| 32 | |
| 33 | subscriptions.subscribeFrontendMessage("TriggerPersistenceWriteState", async (data) => { |
| 34 | await writePersistedState(data.state); |
| 35 | }); |
| 36 | |
| 37 | subscriptions.subscribeFrontendMessage("TriggerPersistenceReadState", async () => { |
| 38 | await readPersistedState(editor); |
| 39 | }); |
| 40 | |
| 41 | subscriptions.subscribeFrontendMessage("TriggerPersistenceWriteDocument", async (data) => { |
| 42 | await writePersistedDocument(data); |
| 43 | }); |
| 44 | |
| 45 | subscriptions.subscribeFrontendMessage("TriggerPersistenceReadDocument", async (data) => { |
| 46 | await readPersistedDocument(data.documentId, editor); |
| 47 | }); |
| 48 | |
| 49 | subscriptions.subscribeFrontendMessage("TriggerPersistenceDeleteDocument", async (data) => { |
| 50 | await deletePersistedDocument(String(data.documentId)); |
| 51 | }); |
| 52 | |
| 53 | subscriptions.subscribeFrontendMessage("TriggerOpenLaunchDocuments", async () => { |
| 54 | // TODO: Could be used to load documents from URL params or similar on launch |
| 55 | }); |
| 56 | } |
| 57 | |
| 58 | export function destroyPersistenceManager() { |
| 59 | const subscriptions = subscriptionsRouter; |
nothing calls this directly
no test coverage detected