Skip to content

Commit

Permalink
Add registerEntryPoint to HmrServer
Browse files Browse the repository at this point in the history
Summary: This diff changes a few things around so that a diff coming on top of this stack will be smaller. The aim of this change is to add a method `registerEntryPoint` which will allow a client to subscribe to updates for multiple bundles.

Reviewed By: gaearon

Differential Revision: D16131963

fbshipit-source-id: d460d6647b15a711021c7a3a51f52486a1aea535
  • Loading branch information
cpojer authored and facebook-github-bot committed Jul 9, 2019
1 parent 88e18b6 commit a622421
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions Libraries/Utilities/HMRClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,20 +101,14 @@ const HMRClient: HMRClientNativeInterface = {
invariant(bundleEntry, 'Missing required paramenter `bundleEntry`');
invariant(host, 'Missing required paramenter `host`');
invariant(!hmrClient, 'Cannot initialize hmrClient twice');

// Moving to top gives errors due to NativeModules not being initialized
const HMRLoadingView = require('./HMRLoadingView');

const wsHostPort = port !== null && port !== '' ? `${host}:${port}` : host;

bundleEntry = bundleEntry.replace(/\.(bundle|delta)/, '.js');

// Build the websocket url
const wsUrl =
`ws://${wsHostPort}/hot?` +
`platform=${platform}&` +
`bundleEntry=${bundleEntry}`;

const client = new MetroHMRClient(wsUrl);
const wsHost = port !== null && port !== '' ? `${host}:${port}` : host;
const client = new MetroHMRClient(
`ws://${wsHost}/hot?bundleEntry=${bundleEntry}&platform=${platform}`,
);
hmrClient = client;

client.on('connection-error', e => {
Expand Down

0 comments on commit a622421

Please sign in to comment.