redux-toolkit icon indicating copy to clipboard operation
redux-toolkit copied to clipboard

Docs: Add simpler Basic Usage example for createListener Middleware (suggestion)

Open kostasx opened this issue 10 months ago • 6 comments

I find the Basic Usage example way too convoluted and definitely not Basic. I suggest this is split into a very simple version for setting up and dispatching an action (I tried to keep it as simple as possible) and an extended version with some of the other options available.

I've also included another listener on the extended version.

P.S. Up to the team and the community to decide, but I find myself in trouble whenever I need to reach out for a very basic setup in order to implement a listener in my code.

kostasx avatar Jan 29 '25 17:01 kostasx

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders
Open Preview

codesandbox[bot] avatar Jan 29 '25 17:01 codesandbox[bot]

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 17c73e49da26be9971de29bdd1a06ce5ac7710e0:

Sandbox Source
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration
rtk-esm-cra Configuration

codesandbox-ci[bot] avatar Jan 29 '25 17:01 codesandbox-ci[bot]

Deploy Preview for redux-starter-kit-docs ready!

Name Link
Latest commit 17c73e49da26be9971de29bdd1a06ce5ac7710e0
Latest deploy log https://app.netlify.com/sites/redux-starter-kit-docs/deploys/679a6a585c13ca0008a01ddf
Deploy Preview https://deploy-preview-4836--redux-starter-kit-docs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Jan 29 '25 17:01 netlify[bot]

Is your concern around the setup part (createListenerMiddleware(), getDefaultMiddleware.concat(listenerMiddleware.middleware)? Or the "things you can do inside the effect callback" part?

markerikson avatar Jan 29 '25 20:01 markerikson

Mostly the effect callback contents. The setup part, is mandatory for a basic example, I guess.

kostasx avatar Jan 29 '25 20:01 kostasx

For a basic example, I think, all the things inside the callback are a bit too much.

kostasx avatar Jan 29 '25 20:01 kostasx