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

Modifing property in causes significant performance degradation. #61

Open
ugoa opened this issue Dec 16, 2015 · 2 comments
Open

Modifing property in causes significant performance degradation. #61

ugoa opened this issue Dec 16, 2015 · 2 comments

Comments

@ugoa
Copy link

ugoa commented Dec 16, 2015

In the didInsertElement hook, one of the properties is explicitly updated,

this.set('bsDateTimePicker', bsDateTimePickerFn);

Which makes the date selecting significantly slower then the native js plugin, and also the ember-cli reports a deprecation warning

DEPRECATION: A property of <perx-dashboard@view:-outlet::ember476> was modified inside the didInsertElement hook. 
You should never change properties on components, services or models during didInsertElement because it causes significant performance degradation.
[deprecation id: ember-views.dispatching-modify-property]

Please kindly refactor this part a bit, the performance could be much boosted.
Cheers.

@FredUK
Copy link

FredUK commented Jul 8, 2016

I've just experienced the same issue and I've solved it by wrapping the setting of my own date property into Ember.run.next. Not nice but seems to work:

{{bs-datetimepicker date=fromDate updateDate=(action 'updateStartDate')}}

  actions: {
    updateStartDate(startDate) {
      // this.set('fromDate', startDate);
      Ember.run.next(this, 'set', 'fromDate', startDate);
    }
  }

Hope that helps.
Fred

@jlami
Copy link

jlami commented Feb 13, 2017

This is still a problem now, but probably due to another problem.

didReceiveAttrs calls _updateDateTimePicker, which updates all the attributes, not only the ones that changed. This seems to trigger a big update on the base datepicker that makes the browser lag. Maybe _updateDateTimePicker should get the attributes that changed so it can check which ones have changed? And then for the date parameter maybe have an extra check to see if the current value in the control is already the same? Something like this?

      let oldDate = dateTimePicker.date();
      let newDate = this.getAttr('date');
      let dateChanged = (!oldDate && newDate || !oldDate.isSame(newDate));

With something like this I got the control much more responsive, though not quite the same as the 'native js' version.

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

No branches or pull requests

3 participants