Clear flow errors

This commit is contained in:
Kai Moseley 2016-11-29 13:57:40 +00:00
parent 6d9c887486
commit 36b5eadc99
2 changed files with 15 additions and 14 deletions

View File

@ -1,16 +1,17 @@
//@flow
type ObjectReducerAction = {
export type ObjectReducerAction = {
type: string,
payload?: Object,
payload?: any,
};
type ObjectReducer = (Object) => (Object, ObjectReducerAction) => Object;
export type ObjectReducerFactory = (structure: Object) => ObjectReducer;
export type ObjectReducer = (state: Object, action: ObjectReducerAction) => Object;
export function objectReducer(reducerStructureDescriptor: Object): ObjectReducer {
const { structure } = reducerStructureDescriptor();
return (state = determineDefaults(reducerStructureDescriptor)(structure), { type, payload } = {}) => {
export function objectReducer(): ObjectReducer {
return (state = {}, { type, payload } = {}) => {
switch (type) {
case 'BLARG!':
return { state, ...reducerStructureDescriptor, ...payload };
return { state, ...payload };
default:
return state;
}

View File

@ -1,18 +1,18 @@
//@flow
import type { ReducerStructure } from '../structure';
export type ObjectReducerAction = {
export type PrimitiveReducerAction = {
type: string,
payload?: Object,
payload?: any,
};
export type ObjectReducerFactory = (structure: Object) => ObjectReducer;
export type ObjectReducer = (state: Object, action: ObjectReducerAction) => Object;
export type PrimitiveReducerFactory = (structure: Object) => PrimitiveReducer;
export type PrimitiveReducer = (state: any, action: PrimitiveReducerAction) => any;
export function arrayReducer<ArrayReducerFactory>(reducerStructureDescriptor: ReducerStructure) {
return(state: Object = calculateDefaults(reducerSructure), { type, payload = {}}: ObjectReducerAction = {}): Object => {
export function primitiveReducer<ArrayReducerFactory>(reducerStructureDescriptor: ReducerStructure) {
return(state: any = '', { type, payload }: PrimitiveReducerAction = {}) => {
switch(type) {
case 'BLARG3':
return [ state, ...payload ];
return payload;
default:
return state;
}