Skip to content

Async event emitters between front/back-endΒ #138

@misterjoecool

Description

@misterjoecool

Problem

Sub-issue #1: Currently, the way the feedback modal works is by handling events that are emitted from both the frontend and the backend.

Sub-issue #2: The main roadblock in the way of finalizing the transfer of event handlers out of the frontend is the way the dblist (list of databases in the sidebar) gets updated. Many event handlers in the backend send a dblist update event out to update the front end.

Sub-issue #3: There are still some filesystem read/write calls in the front end.

Solution

Sub-issue #1: Ideally, this should be refactored to be state dependent rather than event dependent, as it controls the display of the modal. This can be tied into the centralized async event emitter added to frontend/components/app.tsx, in conjunction with migration to reducers from state variables. The goal will be to house modal messages in the store tied to the main app reducer. From there, the async handler can send new messages to the state via main app dispatch, and any other front end feedback can do the same.

Sub-issue #2: Ideally, this should be handled by returning the new dblist changes out of the handler and using that resolved value to update state whenever an action would cause a dblist change. Right now, app.tsx has a useEffect running that listens for those dblist updates every frame. This is inefficient as a frontend concern.

Sub-issue #3: This should be refactored to an async call that requests the backend handle the file system read/write for proper separation of concerns.

Additional information

The spinner currently works in a similar way to feedback. Once all async is completely migrated (including dblist update changes), this spinner can simply be tied to the loading property in the main app state.

πŸ‘¨β€πŸ‘§β€πŸ‘¦ Contributing

  • πŸ™‹β€β™‚οΈ Yes, I'd love to make a PR to implement this feature!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions