apache / apache/cordova-plugin-file
FileWriter is not implementing EventTarget
- Dominant language
- JavaScript
- Stars
- 744
- Forks
- 754
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 1
Description
# Bug Report
## Problem
### What is expected to happen?
According to the provided [TypeScript definitions](https://github.com/apache/cordova-plugin-file/blob/master/types/index.d.ts): `FileWriter extends FileSaver` and `FileSaver extends EventTarget`. [`EventTarget` interface](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) contains `addEventListener` an `removeEventListener` functions.
### What does actually happen?
Functions `addEventListener` and `removeEventListener` are not defined in the `FileWriter` instances.
### Command or Code
```
fileEntry.createWriter(function (fileWriter) {
// It will throw an error about undefined addEventListener on the next line.
fileWriter.addEventListener('writeend', function () {
console.log("Successful file write...");
});
});
```
### Environment, Platform, Device
Samsung tablet with Android 5.
### Version information
```
"cordova-android": "7.0.0",
"cordova-plugin-file": "^6.0.1",
"ionic": "^4.2.1",
```
## Checklist
- [x] I searched for existing GitHub issues
- [ ] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
Contributor guide
Research direction
Start at the FileWriter implementation reached through fileEntry.createWriter and compare it with the inheritance and methods declared in types/index.d.ts. Reproduce the provided addEventListener example on the reported Android setup, then verify that FileWriter instances expose both event-listener functions and support the writeend callback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100