@rbxts/rodux
TypeScript icon, indicating that this package has built-in type declarations

3.0.0-ts.3 • Public • Published
The roblox-ts version of Rodux, A state management library for Roblox inspired by Redux.
 

Installation

You can install it via npm i @rbxts/rodux.

Using Thunk Middleware

if you decide to use the thunk middleware, you will have to explictly set the template argments when creating Rodux.Store, otherwise it will not type correctly.

Example:

import Rodux, { combineReducers, applyMiddleware } from "@rbxts/rodux";
import characterReducer, {
	ICharacterReducer,
	CharacterActions,
} from "./CharacterReducer";

export interface IStore {
	Character: ICharacterReducer;
}

export type StoreActions = CharacterActions;

const reducers = combineReducers<IStore, StoreActions>({
	Character: characterReducer,
});

const store = new Rodux.Store<IStore, StoreActions, Rodux.ThunkDispatch<IStore, {}, StoreActions>>(
	reducers,
	{},
	[Rodux.thunkMiddleware],
);

Explicitly defining the type for Rodux.thunkMiddleware will allow you to get the correct types for the store, otherwise it will be Rodux.Store<any>

If you also use Rodux.loggerMiddleware (or any other middleware) :

const store = new Rodux.Store<IStore, StoreActions, Rodux.ThunkDispatch<IStore, {}, StoreActions>, {}>(
	reducers,
	{},
	[Rodux.thunkMiddleware, Rodux.loggerMiddleware],
);

License

The original Rodux library's License can be found here: Rodux License

Readme

Keywords

Package Sidebar

Install

npm i @rbxts/rodux

Weekly Downloads

21

Version

3.0.0-ts.3

License

none

Unpacked Size

26.4 kB

Total Files

17

Last publish

Collaborators

  • osyris
  • vorlias