Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Cordova File Plugin should be patched, or there should be a way to unpatch things on runtime. #868

Closed
n00dl3 opened this issue Aug 7, 2017 · 3 comments

Comments

@n00dl3
Copy link

n00dl3 commented Aug 7, 2017

I am using angular 4.3 (and zone 0.8.12) and I am experiencing some troubles with the official cordova file plugin. The plugin has a patched version of the FileReader class that does not implement the EventTarget interface. If I understand well what it is done by zone.js to "onProperties" (onload,onerror...) is that they are converted to there zone-ready addEventListener(...) counterpart, so my onerror,onload callback never got trigerred...

I understand that it is a plague to implement all singularity of any library, so maybe there should be a more-generic method like zone.runUnpatched(()=>{}) to get the "original"/unpatched constructor of patched API.

suggestion:

For now, if I run this:

zone.run(()=>{
  let reader = new FileReader();
});

new FileReader() it will call zone's delegated constructor that will transform onProperties to addEventListener. reader being a zone-patched instance of FileReader.

Implementing a method like zone.runUnpatched(()=>{}) that will call the actual non-patched constructor would solve that kind of problem :

zone.runUnpatched(()=>{
  let reader = new FileReader();
});
@JiaLiPassion
Copy link
Collaborator

@n00dl3 , could you provide a reproduce repo?

@n00dl3
Copy link
Author

n00dl3 commented Aug 8, 2017

I guess I can but it will only work on mobile device (not browser) and sounds like a pain in the a** to create. If I just mock cordova's FileReader patch is that okay for you (I just need to create a FileReader that does not implement EventTarget) ?

@JiaLiPassion
Copy link
Collaborator

@n00dl3 , a cordova project or a mock FileReader both works for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants