-
Notifications
You must be signed in to change notification settings - Fork 511
Add pollingInterval option to Charts #704
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
Conversation
Pull Request Test Coverage Report for Build 470
💛 - Coveralls |
packages/clay-charts/src/Chart.js
Outdated
@@ -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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.👍
packages/clay-charts/src/Chart.js
Outdated
@@ -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); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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); | |||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
packages/clay-charts/src/Geomap.js
Outdated
@@ -19,6 +19,8 @@ class Geomap extends Component { | |||
return; | |||
} | |||
|
|||
this._setupPolling(); |
There was a problem hiding this comment.
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
packages/clay-charts/src/Geomap.js
Outdated
@@ -72,6 +74,10 @@ class Geomap extends Component { | |||
return; | |||
} | |||
|
|||
if (this._pollingInterval) { | |||
clearTimeout(this._pollingInterval); | |||
} |
There was a problem hiding this comment.
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
packages/clay-charts/src/Geomap.js
Outdated
}; | ||
|
||
Object.assign(Geomap.prototype, DataComponent); | ||
Object.assign(Geomap.STATE, DataComponent.STATE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as before?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
packages/clay-charts/src/Chart.js
Outdated
|
||
Object.assign(Chart.prototype, ChartBase); | ||
Chart.STATE = ChartBase.STATE; | ||
Chart.STATE = Object.assign({}, ChartBase.STATE, DataComponent.STATE); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
packages/clay-charts/src/Geomap.js
Outdated
}; | ||
|
||
Object.assign(Geomap.STATE, DataComponent.STATE); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
No description provided.