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

issue/1523: added xapi model state functions #1524

Merged
merged 14 commits into from
Oct 25, 2017
Merged

issue/1523: added xapi model state functions #1524

merged 14 commits into from
Oct 25, 2017

Conversation

oliverfoster
Copy link
Member

as per #1523

@oliverfoster oliverfoster self-assigned this Apr 11, 2017
},

triggerState: function() {
Adapt.tirgger("state:change", this.getState());
Copy link
Contributor

Choose a reason for hiding this comment

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

typo tirgger...

@oliverfoster oliverfoster changed the title issue/1523: added array notation state functions issue/1523: added xapi model state functions Apr 11, 2017
result = [];
break;
case "object":
retuls = {};
Copy link
Member

Choose a reason for hiding this comment

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

Typo.

result = [];
break;
case "object":
retuls = {};
Copy link
Member

Choose a reason for hiding this comment

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

Typo?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup

// Unset waiting flag
this.triggerTrackableState.isQueued = false;

}, this), 17)
Copy link
Member

Choose a reason for hiding this comment

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

The 17 here is a magic number. Also, why 17?

Copy link
Member Author

@oliverfoster oliverfoster Sep 13, 2017

Choose a reason for hiding this comment

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

60fps ish. anywhere between 17ms and 40ms is usually good for stuff like this (25-60fps).
a defer would probably suffice but i wanted to group as many model changes as i could into one trigger, these numbers allow for a few short asynchronous model changes to occur before a callback without it seeming too laggy. > 250ms is probably too laggy (4 fps)

var trackable = _.result(this, 'trackable', []);
if (!_.keys(model.changed).find(function(item, index) {
return _.contains(trackable, item);
})) return;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is quite difficult to read. Could we change to something like:

var isTrackable = _.keys(model.changed).find(function(item, index) {
     return _.contains(_.result(this, 'trackable', []), item);
}.bind(this));

if (isTrackable) {
    this.triggerTrackableState();
}


// Skip if trigger queued or adapt hasn't started yet
if (this.triggerTrackableState.isQueued || !Adapt.attributes._isStarted) {
return
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing semi-colon.

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.

4 participants