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

Make Stats class accept stats in constructor #92

Merged
merged 3 commits into from
Aug 26, 2019
Merged

Make Stats class accept stats in constructor #92

merged 3 commits into from
Aug 26, 2019

Conversation

xintongxia
Copy link
Contributor

No description provided.

@coveralls
Copy link

coveralls commented Aug 25, 2019

Coverage Status

Coverage increased (+0.5%) to 49.244% when pulling 83b7c0b on xx/stats into 6b69db2 on master.


* `id` (`String`) - the id of the `Stats` object.
* `stats` (`String`) - the list of stats. Each element in the stats could be either`Stat` object or `{id, type}` (type is optional, default is `count`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: stats type: String[] | Object[] or (String | Object)[]

An alternative is to make type an Object map with ids as keys. This way we could separating id (easy to use in code) from name (being a printable, human readable name to use in the stats widget).

new Stats({
  id, 
  stats: {
    count: {name: 'Count', type: 'count', resetOnUpdate: true}
  }
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do another PR to resolve this

@@ -154,7 +154,7 @@ export default class StatsWidget {
}

_createDOMStats() {
if (this.stats && this.stats.size) {
if (this.stats instanceof Stats) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

assert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

stats could be empty

@xintongxia xintongxia merged commit dcdfb62 into master Aug 26, 2019
@xintongxia xintongxia deleted the xx/stats branch August 26, 2019 17:06
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