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

Improve knockout usage with the Cesium Inspector #4857

Merged
merged 5 commits into from
Jan 12, 2017

Conversation

austinEng
Copy link
Contributor

Fixes #3747

@@ -104,247 +104,243 @@ define([
* @type {Boolean}
* @default false
*/
this.frustums = false;
this.frustums = knockout.observable(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

We use the knockout es5 plugin instead of creating observables directly so users can access observable properties the same way they would regular ones. So instead of creating the observable here, knockout.track creates all the observables behind the scenes.

* @type {String}
* @default '1 of 1'
*/
this.depthFrustumText = knockout.observable('1 of 1');
Copy link
Contributor

Choose a reason for hiding this comment

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

I would default this to ''

that._scene.debugShowFrustums = false;
}
return true;
this.frustums.subscribe(function(val) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any time we do a subscribe, we need to do dispose of it when the widget is destroyed. So do something like

this._frustumsSubscription = this.frustums.subscribe(...)

then in CesiumInspectorViewModel.prototype.detroy do this._frustumsSubscription.dispose()

Copy link
Contributor

Choose a reason for hiding this comment

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

Same for the subscriptions below

@@ -434,13 +444,12 @@ define([
return true;
});


Copy link
Contributor

Choose a reason for hiding this comment

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

whitespace

eventHandler.setInputAction(selectTile, ScreenSpaceEventType.LEFT_CLICK);
} else {
eventHandler.removeInputAction(ScreenSpaceEventType.LEFT_CLICK);
}
});

knockout.track(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

Change this back to use the second argument to define which properties we want to convert to observables. We don't want it to use every property on this

@hpinkos
Copy link
Contributor

hpinkos commented Jan 12, 2017

Good start here @austinEng! That clears up a lot of the weirdness.
Those are all the comments I have for now. Let me know if you have any questions, I was the one that originally wrote this widget.

@austinEng
Copy link
Contributor Author

Thank you for the feedback @hpinkos. Updated.

that._performanceDisplay = new PerformanceDisplay({
container : that._performanceContainer
});
} else {
that._performanceContainer.innerHTML = '';
}
return true;
});

this._showPrimitiveBoundingSphere = createCommand(function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't being used anymore, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, nevermind. I see it's being used in multiple places, just not as a knockout binding.

@hpinkos
Copy link
Contributor

hpinkos commented Jan 12, 2017

@pjcozzi do we need to worry about breaking changes here, or can we just make a note in CHANGES.md

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 12, 2017

No concern about breaking changes.

@hpinkos
Copy link
Contributor

hpinkos commented Jan 12, 2017

Great work here @austinEng, thanks!

@hpinkos hpinkos merged commit 65f8749 into CesiumGS:master Jan 12, 2017
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.

3 participants