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

FilesEngine is a redundant interface with HasFileData and access to inner event types #1920

Open
jkelleyrtp opened this issue Feb 9, 2024 · 0 comments
Labels
html Related to the html crate tweak Small changes to improve experience

Comments

@jkelleyrtp
Copy link
Member

jkelleyrtp commented Feb 9, 2024

Specific Demand

We expose the FileEngine object which used to basically be a cache of the renderer's native event, allowing access to dragged/dropped files. Now that events have the native event type in them, this is no longer necessary! We should simply move these methods on the events themselves, simplifying the API and simplifying code that uses them.

For example, the snippet from our file_upload example

        if let Some(file_engine) = &evt.files() {
            let files = file_engine.files();
            for file_name in &files {
                if let Some(file) = file_engine.read_file_to_string(file_name).await {
                    files_uploaded.write().push(file);
                }
            }
        }

could just be simplified to

            for file in evt.files() {
                if let Ok(contents) = file.read_to_string().await{
                    files_uploaded.write().push(contents);
                }
            }

This might require a type like a VirtualFile or something like that that implements the Read trait - or some reworking of methods, but overall the FileEngine object is awkward now.

@jkelleyrtp jkelleyrtp self-assigned this Feb 9, 2024
@ealmloff ealmloff added tweak Small changes to improve experience html Related to the html crate labels Feb 10, 2024
@jkelleyrtp jkelleyrtp added this to the 0.5.0: Signals milestone Feb 23, 2024
@jkelleyrtp jkelleyrtp removed their assignment Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
html Related to the html crate tweak Small changes to improve experience
Projects
Status: No status
Development

No branches or pull requests

2 participants