Skip to content

Instantly share code, notes, and snippets.

@DanielKag
DanielKag / pipe.js
Last active November 6, 2017 03:57
// We're going to create our own pipe function!
// Some basic functions for easily understand the pipe function.
// We'll combine those three function and send the value 4 to it.
// Getting result of - 'The numner is: 10'
const add1 = x => x + 1;
const mul2 = x => x * 2;
const title = x => `The number is: ${x}`;
import {Reducer} from 'redux';
// The IState interface.
// It's empty becuase each state looks differntly.
export interface IState {};
// That's the action we send to our reducer for initializie
// No switch case should catch this action, it's for initialization only
export const INIT_ACTION = 'HIGH_ORDER_INIT_ACTION';
// IState is just an empty interface and all states should extend it.
export interface IExampleState extends IState {
parameter1: number,
parameter2: string[]
};
export const exampleInitialState: IExampleState = {
parameter1: 0,
parameter2: []
};
export interface ITabState extends IState {
selectedTab: number;
};
export const tabInitialState: ITabState = {
selectedTab: 0,
};
// We use a curry here so we could use our extendReducer Function
// An HOR can get as many arguments as it needs.
// Main public safes state
export interface ISafesState extends ISafesBaseState,
IErrorState,
IMasterDetailsState,
ITabState
{}
// Private base safe state
interface ISafesBaseState extends IState {
dataListSettings: IFlattenState;