File tree Expand file tree Collapse file tree 2 files changed +26
-8
lines changed
packages/node_modules/overmind-devtools-client/src Expand file tree Collapse file tree 2 files changed +26
-8
lines changed Original file line number Diff line number Diff line change @@ -12,10 +12,18 @@ class WebsocketConnector {
1212 private callbacks : {
1313 [ event : string ] : Function [ ]
1414 } = { }
15- private socket = new WebSocket ( 'ws://localhost:3031?devtools=1' ) // TODO should be able to configure
15+ private socket : WebSocket ;
1616 private messagesBeforeConnected : Array < [ string , any , any ] > = [ ]
1717 private isOpen = false
18- constructor ( ) {
18+
19+
20+ public open ( port :string ) // TODO: return Promise so we can wait for it
21+ {
22+ if ( this . socket )
23+ {
24+ throw new Error ( "TODO: Socked already open, what now?" ) ;
25+ }
26+ this . socket = new WebSocket ( `ws://localhost:${ port } ?devtools=1` )
1927 this . socket . onmessage = ( message ) => {
2028 const parsedMessage = JSON . parse ( message . data )
2129
Original file line number Diff line number Diff line change 11import { OnInitialize } from 'overmind'
22
33const onInitialize : OnInitialize = async ( { state, effects } , app ) => {
4- const port = await effects . storage . get < string > ( 'currentPort' )
5- const runtimeHost = await effects . storage . get < string > ( 'runtimeHost' )
4+
5+ // We cannot use storage here since it depends on connector, which is not open yet since we do not know the host!
6+ // let port = await effects.storage.get<string>('currentPort')
7+ // const runtimeHost = await effects.storage.get<string>('runtimeHost')
8+
9+ let port = "3301" ; // TODO: const default port somewhere
10+ if ( window [ '__OVERMIND_DEVTOOLS_BACKEND_PORT__' ] )
11+ {
12+ port = window [ '__OVERMIND_DEVTOOLS_BACKEND_PORT__' ] ;
13+ }
614
715 if ( port ) {
816 state . port = port
917 }
1018
11- if ( runtimeHost ) {
12- state . runtimeHost = runtimeHost
13- }
19+ effects . connector . open ( state . port )
20+
21+ // if (runtimeHost) {
22+ // state.runtimeHost = runtimeHost
23+ // }
1424
1525 effects . connector . onMessage ( app . actions . onMessage )
16- effects . connector . connect ( state . port )
26+ // effects.connector.connect(state.port) // This should no longer be needed. DevtoolBackend does nothing when receing.
1727}
1828
1929export default onInitialize
You can’t perform that action at this time.
0 commit comments