https://github.com/paramsinghvc/redux-operation
https://github.com/paramsinghvc/redux-operation
Last synced: 29 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/paramsinghvc/redux-operation
- Owner: paramsinghvc
- License: mit
- Created: 2019-05-20T03:49:06.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T03:45:53.000Z (over 3 years ago)
- Last Synced: 2025-08-08T19:48:33.799Z (12 months ago)
- Language: TypeScript
- Size: 1.08 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status][build-shield]]()
[![MIT License][license-shield]][license-url]
[![Contributors][contributors-shield]]()
[![LinkedIn][linkedin-shield]][linkedin-url]
Create Redux Operation
A utility to simplify creation of redux operations like loading, success, failure automatically
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
.
NPM Link
## Table of Contents
- [About the Project](#about-the-project)
- [Built With](#built-with)
- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)
- [Acknowledgements](#acknowledgements)
## About The Project
A utility to simplify creation of redux operations like loading, success, failure automatically.
### Built With
- [TypeScript](https://www.typescriptlang.org/)
- [ParcelJS](https://parceljs.org/)
## Getting Started
### Prerequisites
- Redux
### Installation
```sh
npm i @mollycule/redux-operation -S
```
## Usage
1. Wrap the root app component with `redux-hook` provider by calling `createStoreContext` while specifying the shape of Redux App RootState into Generic Parameter.
```ts
import createReduxOperation, {
actionFlags,
augmentReducer,
IReduxOperations,
IAction
} from "@mollycule/redux-operation";
const {
actions: [authRequest, authSuccess, authFailure],
constants: authConstants,
reducer: authenticationReducer
} = createReduxOperation("AUTHENTICATE");
export { authSuccess, authRequest, authFailure };
export interface ILoginState {
metaProp: string;
}
const initialState = {
metaProp: ""
};
const loginReducer = (
state = initialState,
action: IAction
) => {
switch (action.type) {
case authConstants.get(actionFlags.REQUEST):
return {
...state,
metaProp: "SET NOW"
};
default:
return state;
}
};
export interface ILoginStateAugmented extends ILoginState {
auth: IReduxOperations;
}
export default augmentReducer(loginReducer)({
auth: authenticationReducer
});
```
## Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## License
Distributed under the MIT License. See `LICENSE` for more information.
## Contact
Param Singh - [@paramsinghvc](https://github.com/paramsinghvc) - paramsinghvc@gmail.com
Project Link: [https://github.com/paramsinghvc/redux-operation](https://github.com/paramsinghvc/redux-operation)
## Acknowledgements
- [GitHub Emoji Cheat Sheet](https://www.webpagefx.com/tools/emoji-cheat-sheet)
- [Img Shields](https://shields.io)
[build-shield]: https://img.shields.io/badge/build-passing-brightgreen.svg?style=flat
[contributors-shield]: https://img.shields.io/badge/contributors-1-orange.svg?style=flat
[license-shield]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: https://choosealicense.com/licenses/mit
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat&logo=linkedin&colorB=0077B5
[linkedin-url]: https://www.linkedin.com/in/paramsinghvc
[product-screenshot]: https://user-images.githubusercontent.com/4329912/57970750-b895d200-79a2-11e9-9fdf-fcf80c8fce28.png