Skip to content

Conversation

julien
Copy link
Contributor

@julien julien commented Mar 7, 2018

No description provided.

@julien julien changed the title Add polling_interval option to Charts Add pollingInterval option to Charts Mar 7, 2018
@julien julien requested a review from jbalsas March 7, 2018 12:38
@coveralls
Copy link

coveralls commented Mar 7, 2018

Pull Request Test Coverage Report for Build 470

  • 32 of 38 (84.21%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.08%) to 81.908%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/clay-charts/src/ChartBase.js 12 14 85.71%
packages/clay-charts/src/Geomap.js 1 5 20.0%
Totals Coverage Status
Change from base Build 459: 0.08%
Covered Lines: 4511
Relevant Lines: 4774

💛 - Coveralls

@@ -11,7 +12,8 @@ import templates from './Chart.soy.js';
class Chart extends Component {}

Object.assign(Chart.prototype, ChartBase);
Chart.STATE = ChartBase.STATE;
Object.assign(Chart.prototype, DataComponent);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not Object.assign(Chart.prototype, DataComponent, ChartBase); all in one line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.👍

@@ -11,7 +12,8 @@ import templates from './Chart.soy.js';
class Chart extends Component {}

Object.assign(Chart.prototype, ChartBase);
Chart.STATE = ChartBase.STATE;
Object.assign(Chart.prototype, DataComponent);
Chart.STATE = Object.assign(ChartBase.STATE, DataComponent.STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this rather be Object.assign({}, ChartBase.STATE, DataComponent.STATE)? Otherwise, aren't we mutating ChartBase.STATE?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes we are, good catch thanks

@@ -77,6 +76,7 @@ const ChartBase = {
}

this._resolveData(this.data).then(data => {
this._setupPolling();
Copy link
Contributor

Choose a reason for hiding this comment

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

This should go to DataComponent, as ChartBase has no knowledge at all about polling

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this could go inside the _resolveData method, right before resolving the Promise?

@@ -103,6 +103,10 @@ const ChartBase = {
return;
}

if (this._pollingInterval) {
clearInterval(this._pollingInterval);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should go to DataComponent, as ChartBase has no knowledge at all about polling

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, but ChartBase (or Chart if you prefer) will have to call this method defined in DataComponent since it can't be called disposed. Do you agree?

@@ -19,6 +19,8 @@ class Geomap extends Component {
return;
}

this._setupPolling();
Copy link
Contributor

Choose a reason for hiding this comment

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

This should go to DataComponent, as ChartBase has no knowledge at all about polling

@@ -72,6 +74,10 @@ class Geomap extends Component {
return;
}

if (this._pollingInterval) {
clearTimeout(this._pollingInterval);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should go to DataComponent, as ChartBase has no knowledge at all about polling

};

Object.assign(Geomap.prototype, DataComponent);
Object.assign(Geomap.STATE, DataComponent.STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as before?

Copy link
Contributor Author

@julien julien Mar 7, 2018

Choose a reason for hiding this comment

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

Here, I'm mutating Geomap.prototype which is what I want and doing the same with Geomap.STATE which is another object so I don't really want to mix the two, but I'm not modifying DataComponent or DataComponent.STATE, did I miss anything?

Copy link
Contributor Author

@julien julien Mar 7, 2018

Choose a reason for hiding this comment

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

It probably makes more sense to have Geomap extend from DataComponent (and probably do the same for Chart not ChartBase) since itself extends Component, and just copy the STATE over. What do you think?

jbalsas
jbalsas previously requested changes Mar 8, 2018

Object.assign(Chart.prototype, ChartBase);
Chart.STATE = ChartBase.STATE;
Chart.STATE = Object.assign({}, ChartBase.STATE, DataComponent.STATE);
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 that we probably don't need to merge DataComponent.STATE here, since metal will pick it up from the class chain. Could you double check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you're right, this is not needed. Thanks.

};

Object.assign(Geomap.STATE, DataComponent.STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we already extend DataComponent, is this really necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, you're right.

@@ -103,6 +103,8 @@ const ChartBase = {
return;
}

this.cleanup();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need to add this additional lifecycle method? Wouldn't it be enough to just implement disposed() in DataComponent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're right; that's the thing to do, thanks.

@jbalsas jbalsas dismissed their stale review March 12, 2018 13:07

Changes applied

@jbalsas jbalsas merged commit 0b741aa into liferay:develop Mar 12, 2018
@julien julien deleted the issue-544 branch March 13, 2018 08:19
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