+1
The W3C standard that the file plugin currently implements is an old
standard that has since been abandoned. There is two replacement
standards, Filesystem[1] and Filesystem Access[2] which should be on our
radar but it definitely will be quite a project would involve a rewrite.
Admittedly I don't foresee that happening anytime soon.
So because the current implemented standard is abandoned, I don't
foresee any problems deviating from the standard if it means it can make
the API less cumbersome to use. Using promises will enable the use of
the async/await syntax as well.
There are some key things I'd like to note though (and I know some of
these were already mentioned in the GH thread but I'm re-iterating here
for record-keeping purposes):
1. We should maintain backwards compatibility.
The API should be able to accept the original method signatures using
callbacks, in addition to, being able to return a promise that gets
resolved/rejected appropriately. Removing callbacks method is a
significant breaking change that we should avoid.
2. The W3C filesystem spec is large and distributed and not all parts of
it is deprecated. For example, the FileReader, FileWriter, and File
objects are all part of a different, still living specification and thus
those APIs should continue to match the specification. Deviating API
signatures on anything currently living can cause issues in the future
with Cordova's "Cease to exists" goals. Therefore care should be taken
to only modify the API that is part of the deprecated File API standard[3].
[1] https://fs.spec.whatwg.org/
[2] https://wicg.github.io/file-system-access/
[3] https://www.w3.org/TR/2012/WD-file-system-api-20120417/
On 2024-10-03 09:23, Manuel Beck wrote:
Hi,
I would like to add Promises to cordova-plugin-file. The goal is to get out of
the callback hell, make the code more readable, easier to setup and to maintain.
I opened an Issue for discussion on the plugin:
https://github.com/apache/cordova-plugin-file/issues/637
Regards,
Manuel
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org