1.0.0 • Published 2 years ago

@nait-aits/redux v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Installation

// with npm
npm install @nait-aits/redux

Update Notes

  • May 16, 2022 - React 18. May work with older versions of react. YMMV.

Usage Example (duck file)

import { createAsyncAction, ReducerState } from "@nait-aits/redux";

const controlName = "samplePage";

type LoadTestData = {
    data: string;
};

var loadTest = createAsyncAction<LoadTestData, { id: string | number }, State>({
  actionPrefix: controlName,
  actionName: "loadTestData",
  url:"https://someUrl",
  pending: (state, action) => {
    state.testDataState.isLoading = true;
    state.testDataState.data = undefined;
  },
  fulfilled: (state, action) => {
    state.testDataState.isLoading = false;
    state.testDataState.data = action.payload;
  },
  rejected: (state, action) => {
    state.testDataState.isLoading = false;
    state.testDataState.error = action.payload;
  },
});

type State = {
  testDataState: ReducerState<LoadTestData>;
};

var slice = createSlice({
  name: controlName,
  initialState: {
    testDataState: {
      isLoading: false,
    },
  } as State,
  reducers: {},
  extraReducers: {
    ...loadTest.reducer,
  },
});

const ret = {
  reducer: {
    [controlName]: slice.reducer,
  },
  actions: {
    [controlName]: {
      ...slice.actions,
      loadTest: loadTest.action,
    },
  },
};
1.0.0

2 years ago

0.5.4

2 years ago

0.5.3

2 years ago

0.5.5

2 years ago

0.5.2

3 years ago

0.5.0

3 years ago

0.5.1

3 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago