-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: extract DevTools data from ExtensionData (#10589)
- Loading branch information
1 parent
0640da7
commit 9654563
Showing
8 changed files
with
68 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,21 +2,28 @@ import {m} from 'malevic'; | |
import {sync} from 'malevic/dom'; | ||
import Body from './components/body'; | ||
import Connector from '../connect/connector'; | ||
import type {ExtensionData} from '../../definitions'; | ||
import type {DevToolsData, ExtensionData} from '../../definitions'; | ||
|
||
declare const __CHROMIUM_MV3__: boolean; | ||
|
||
function renderBody(data: ExtensionData, actions: Connector) { | ||
sync(document.body, <Body data={data} actions={actions} />); | ||
function renderBody(data: ExtensionData, devToolsData: DevToolsData, actions: Connector) { | ||
sync(document.body, <Body data={data} devtools={devToolsData} actions={actions} />); | ||
} | ||
|
||
async function start() { | ||
const connector = new Connector(); | ||
window.addEventListener('unload', () => connector.disconnect()); | ||
|
||
const data = await connector.getData(); | ||
renderBody(data, connector); | ||
connector.subscribeToChanges((data) => renderBody(data, connector)); | ||
let [data, devToolsData] = await Promise.all([ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
connector.getData(), | ||
connector.getDevToolsData(), | ||
]); | ||
renderBody(data, devToolsData, connector); | ||
connector.subscribeToChanges(async (data_) => { | ||
data = data_; | ||
devToolsData = await connector.getDevToolsData(); | ||
This comment has been minimized.
Sorry, something went wrong.
alexanderby
Member
|
||
renderBody(data, devToolsData, connector); | ||
}); | ||
} | ||
|
||
start(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You still have to wait. Maybe it's worth first rendering the UI with some fake UI data, and then render again when the dev tools data finished loading?