Skip to content

Refactoring Redux code: hooks, thunks, and redux-toolkit #2042

Open
@lindapaiste

Description

@lindapaiste
Collaborator

Most of the Redux code is this package was written years ago and has not been touched since. In that time, Redux has come a long way! The bad news is that this codebase goes against a lot of the Redux Best Practices. The good news is that the newer ways of doing things are much easier and involve a lot less boilerplate.

Some things which can be improved/changed:

  • Can use createSlice which automatically creates the action creators for a reducer so that you don't need to define a bajillion constants or define basic action creator functions. This can be tackled one "slice" at a time, as Redux Toolkit is fully compatible with old/vanilla Redux.
  • Can use createAsyncThunk to automatically dispatch pending, error and fulfilled actions for each asynchronous action.
  • Can use useSelector and useDispatch hooks instead of the connect HOC.

I can do a lot of this myself, but I wanted to post it as a discussion first because I don't want to waste time rewriting code if it's not wanted.

Activity

welcome

welcome commented on Jul 18, 2022

@welcome

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.

kjhollen

kjhollen commented on Aug 15, 2022

@kjhollen
Member

thank you @lindapaiste! the editor is currently in maintenance mode as we transition to new leadership (see #2010). hope to have an update next month!

added
Priority:HighShould be addressed soon but not critical
Type:TaskTasks tied specifically to developer operations and maintenance
EnhancementImprovement to an existing feature
and removed
Needs DiscussionRequires further conversation or consensus
on Oct 19, 2023
changed the title [-][Discussion] refactoring Redux code: hooks, thunks, and redux-toolkit[/-] [+]Refactoring Redux code: hooks, thunks, and redux-toolkit[/+] on Nov 30, 2023
mrkirthi-24

mrkirthi-24 commented on Jan 4, 2024

@mrkirthi-24

Is this issue open?

lindapaiste

lindapaiste commented on Jan 4, 2024

@lindapaiste
CollaboratorAuthor

Is this issue open?

Yes! It's a broad topic and a lot of work has been done already but it's not complete.

As far as using hooks instead of connect, I think we've got that pretty much everywhere...if you include the PRs that haven't been merged.

We finally merged in a PR that enables Redux Toolkit but most of the reducers haven't been converted. I've only done the toast, assets, and ide so far.

We have not done anything yet with createAsyncThunk (or RTK query).

Maybe I need to make a checklist. If there's a particular piece that you want to work on you should search the open PRs to see if it's mentioned.

https://github.com/processing/p5.js-web-editor/pulls?q=is%3Apr+is%3Aopen+redux

19 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementImprovement to an existing featurePriority:HighShould be addressed soon but not criticalType:TaskTasks tied specifically to developer operations and maintenance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @kjhollen@lindapaiste@raclim@PiyushChandra17@mrkirthi-24

      Issue actions

        Refactoring Redux code: hooks, thunks, and redux-toolkit · Issue #2042 · processing/p5.js-web-editor