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

dataDidChange fires twice #46

Closed
andrewmtoy opened this issue Mar 19, 2016 · 10 comments
Closed

dataDidChange fires twice #46

andrewmtoy opened this issue Mar 19, 2016 · 10 comments

Comments

@andrewmtoy
Copy link

Hey @Glavin001, thanks for creating this library!

I noticed today that the dataDidChange method fires twice after initial render for all subsequent data attribute changes. It looks like you're registering the observer a second time in the didInsertElement method.

This has caused rendering issues with the C3 library because chart.load is invoked twice in quick succession.

What is the use case for notifying components of changes from the controller with 'notifyPropertyChange'? Couldn't we just pass in 'data' and trigger chart.load in a 'didReceiveAttrs' life cycle hook? I think a good fix for this bug would be to delete 'didInsertElement' entirely.

I have a bug demo repo set up here: https://github.com/andrewmtoy/ember-c3-bug-demo.

I believe that this pull request is solving this issue using the debouncer method.

Let me know what you think or if you'd like me to create pull request with these changes.

Thanks!
Andrew

@Glavin001
Copy link
Owner

Hi @andrewmtoy. Thanks for creating this issue. In your demo that reproduces the bug, have you tried and confirmed that #44 fixes this issue? If so, I will merge immediately.

There have likely been a lot of changes to Ember since this package was created. I think removing didInsertElement and update how things work internally makes sense. I would be happy to review and merge a Pull Request for this functionality. Thanks in advance!

@andrewmtoy
Copy link
Author

#44 does not fix the duplicate observer being instantiated, but it does fix the C3 rendering issue I was seeing. I'll take some time this week and send over a pull request with the changes I mentioned.

@jsvg
Copy link
Collaborator

jsvg commented Apr 11, 2016

@andrewmtoy any update on this? would be able to take a second look if not

@andrewmtoy
Copy link
Author

@jsvg, I'm going to take a shot at this tomorrow.

@andrewmtoy
Copy link
Author

Hey @jsvg, @Glavin001. I took a look at using the new component lifecycle hooks in this addon. Here is my first attempt. https://github.com/andrewmtoy/ember-c3/tree/use-new-component-lifecycle-hooks

I've been using this in my project today, and everything seems to be working fine.

Let me know what you think. If you guys like it, I'll add tests and open a pr.

@jsvg
Copy link
Collaborator

jsvg commented Apr 13, 2016

This seems to solve my case for the time being!

@andrewmtoy
Copy link
Author

@Glavin001, if you're cool with this, I'll add tests and open a pr.

@jsvg
Copy link
Collaborator

jsvg commented Apr 16, 2016

Actually @andrewmtoy, in my case I'm modifying chart parameters (axis, groupby, etc) with user input options. Updating these options requires different computed properties on the controller to update. Since these cps are dependent on different promises, which resolve at different times, the graph still renders before all the data is available so I still need the debouncer to provide a semblance of control...

That said, I did a total rewrite of the component. Compliant with current ember coding practices.

@Glavin001
Copy link
Owner

@jsvg your rewrite looks great! Very concise. I think a fresh start would be good, since there have been many changes, to Ember.js and with the availability of ES6, since Ember-C3 was first created.

I think the only thing I see that is missing is the Component's sendAction events: https://github.com/Glavin001/ember-c3/blob/master/addon/components/c3-chart.js#L173-L188

'oninit',
'onrendered',
'onmouseover',
'onmouseout',
'onresize',
'onresized'

@andrewmtoy & @jsvg : I would love to see a Pull Request that meets all of your needs and cleans up the code. I'm currently finishing up final exams for this semester and writing my thesis. So I likely will be more available starting in early May. Before then, I'll still do my best to review any Pull Requests that come my way. Thanks in advance and great work!

@maxwondercorn
Copy link
Collaborator

Issues should be resolved with prs #75 and #79. Updated version will published after checklist in issue #77 are completed

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

4 participants