Skip to content

Fix example 5.5 and move to ECMAScript2015 - #358

Merged
markafoltz merged 1 commit into
w3c:gh-pagesfrom
kenchris:example5.5
Oct 21, 2016
Merged

markafoltz merged 1 commit into
w3c:gh-pagesfrom
kenchris:example5.5

Conversation

@kenchris

Copy link
Copy Markdown
Contributor

Fix errors in example 5.5 like missing reconnectBtn element and move to newer ECMAScript features where it makes sense.

Comment thread index.html Outdated
var disconnectBtn = document.getElementById("disconnectBtn");
var stopBtn = document.getElementById("stopBtn");
stopBtn.onclick = function () { connection && connection.terminate(); };
let stopBtn = document.querySelector("#stopBtn");

@markafoltz markafoltz Oct 10, 2016 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use const instead of let for the *Btn variables?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Comment thread index.html Outdated
connection.onterminate();
connection.onterminate = undefined;

connection.terminate();

@markafoltz markafoltz Oct 10, 2016 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could terminate the presentation when it's reconnected to, per example 5.3, if the old connection hasn't fired onclose yet.

If we want to guarantee that at most one connection to the presentation is open, then maybe this could be:

if (connection && connection != newConnection && connection.state != 'closed') {
  connection.onclosed = undefined;
  connection.close();
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, incorporated

Comment thread index.html Outdated
let disconnectBtn = document.querySelector("#disconnectBtn");

stopBtn.onclick = _ => {
connection && connection.terminate();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'll need && here and below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both seems to work, but let me make the change

@markafoltz markafoltz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one more fix. Thanks for the PR!

Comment thread index.html

function setConnection(newConnection) {
// Disconnect from existing presentation, if not attempting to reconnect
if (connection && connection != newConnection && connection.state != 'closed') {

@markafoltz markafoltz Oct 11, 2016 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&& should be &&

@markafoltz

Copy link
Copy Markdown
Contributor

To move things forward I'll merge this and submit a follow-up pull request to make any necessary further changes.

@markafoltz
markafoltz merged commit 5d2869b into w3c:gh-pages Oct 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants