Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix example 5.5 and move to ECMAScript2015 #358

Merged
merged 1 commit into from
Oct 21, 2016

Conversation

kenchris
Copy link
Contributor

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

var disconnectBtn = document.getElementById("disconnectBtn");
var stopBtn = document.getElementById("stopBtn");
stopBtn.onclick = function () { connection && connection.terminate(); };
let stopBtn = document.querySelector("#stopBtn");
Copy link
Contributor

@markafoltz markafoltz Oct 10, 2016

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
Contributor Author

Choose a reason for hiding this comment

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

sure

connection.onterminate();
connection.onterminate = undefined;

connection.terminate();
Copy link
Contributor

@markafoltz markafoltz Oct 10, 2016

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
Contributor Author

Choose a reason for hiding this comment

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

ok, incorporated

let disconnectBtn = document.querySelector("#disconnectBtn");

stopBtn.onclick = _ => {
connection && connection.terminate();
Copy link
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
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

Copy link
Contributor

@markafoltz markafoltz left a comment

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!


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

@markafoltz markafoltz Oct 11, 2016

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
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