peterfreeman / ngx-dropzone

A highly configurable dropzone component for Angular.
133 stars 56 forks source link

Support for ChangeDetection.OnPush Components #95

Open leptoquark1 opened 3 years ago

leptoquark1 commented 3 years ago

I've the issue that the changes of any input to the preview components have no visible affect when the ChangeDetection strategy of the wrapping component is OnPush.

I can call ChangeDetectorRef.markForCheck only guessing when the preview component is ready

setTimeout(() => this.cdr.markForCheck(), 500);

Since the readFile method is async:

https://github.com/peterfreeman/ngx-dropzone/blob/c255e75d140346490fe822a63aef77218825d3e1/projects/ngx-dropzone/src/lib/ngx-dropzone-preview/ngx-dropzone-preview.component.ts#L93

you'll need either emit an event when renderImage Method:

https://github.com/peterfreeman/ngx-dropzone/blob/c255e75d140346490fe822a63aef77218825d3e1/projects/ngx-dropzone/src/lib/ngx-dropzone-preview/ngx-dropzone-image-preview/ngx-dropzone-image-preview.component.ts#L45

is ready and the view value is updated or the library should switch to OnPush Strategy as well.

@peterfreeman What do you think?

peterfreeman commented 3 years ago

Hey there,

thanks for your feedback. I think the cleaner way would be to use OnPush change detection within the library as well. I am planning to re-implement the package and add some new functionality during the next weeks anyway, so I will keep this in mind.

Happy coding! 🤓

gitalvininfo commented 3 years ago

Hi @peterfreeman

Can I ask if what is the status of this issue? I'm having the same issue in which my component uses OnPush change detection

Thanks for this library. Really helpful.

peterfreeman commented 2 years ago

Hi @gitalvininfo,

I am still working on the update in the background, so it will still take a while. I am sorry for your inconveniences but hopefully you can work around them.

Happy coding! 🤓

gitalvininfo commented 2 years ago

@peterfreeman

No problem! I already made a workaround by removing the changeDection.OnPush 😂. I decided not to care. Modern problem requires modern solution they say.

Thanks again for this library, it helped improve my UX in my app.