valkn0t
12/28/2019 - 2:54 AM

BareBones Reducks

import { createRoutine } from "redux-saga-routines";
import { Reducer } from "redux";
import { takeLatest, all } from "redux-saga/effects";
import * as _ from "lodash";
import { createSelector } from "reselect";
import { denormalize } from "normalizr";

const MODULE_NAME: string = "Duck";

export interface IDuckState {
  initialized: boolean;
}

export const initialDuckState: IDuckState = {
  initialized: false,
};

export class DuckActionTypes {
  static readonly RESET: string = `@@${MODULE_NAME}/RESET`;
  static readonly INIT: string = `@@${MODULE_NAME}/INIT`;
}

export class DuckReset {
  readonly type = DuckActionTypes.RESET;
  constructor() {}
}
export class DuckInit {
  readonly type = DuckActionTypes.INIT;
  constructor() {}
}
// Routine classes

export type DuckAction = DuckReset;

export const DuckStateReducer: Reducer<IDuckState, DuckAction> = (
  state = initialDuckState,
  action: DuckAction
) => {
  switch (action.type) {
    case DuckActionTypes.INIT: {
      return {
        initialized: true,
      };
    }
    case DuckActionTypes.RESET: {
      return _.cloneDeep(initialDuckState);
    }
    default:
      return state;
  }
};

// Selectors

export abstract class DuckSelectors {}

// Sagas
function* loadDuckSaga() {}

export function* rootDuckSaga() {
  yield all([
    // takeLatest(DuckLoadRoutine.TRIGGER, loadDuckSaga)
  ]);
}

// export * from './customRenders';
// export * from './state';
// export * from './actionTypes';
// export * from './routines';
// export * from './actions';
// export * from './reducer';
// export * from './selectors';
// export * from './sagas';