brunch / auto-reload-brunch

Adds automatic browser reloading support to brunch.
88 stars 30 forks source link

Update readme and connection settings #90

Closed clarknelson closed 4 years ago

clarknelson commented 4 years ago

I noticed a problem with how the docs recommend to attach the front-end settings:

<script>
    window.brunch = window.brunch || {};
    window.brunch['auto-reload'].disabled = true;
</script>

Results in "Can not set the property "disabled" of undefined.

<script>
    window.brunch = window.brunch || {};
    window.brunch['auto-reload'] = window.brunch['auto-reload'] || {};
    window.brunch['auto-reload'].disabled = true;
</script>

The program works as expected when I create the auto-reload object on the brunch object first.

I've also modified the connect() function in the front-end code.

The function should check first if auto-reload is enabled before creating the Websocket call.

Finally I added a check for https / http. The Websocket will not work unless it is wss from https and vice versa. So it's a fair assumption that if the page is running at https: then the Websocket will connect at wss.

Hope this gets merged! Let me know if you have any questions or concerns.

paulmillr commented 4 years ago

Thank you very much!

clarknelson commented 4 years ago

My pleasure! Thanks for merging