Skip to content

Commit

Permalink
fix: index flow type exports
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Jun 19, 2018
1 parent 57fc104 commit ad09127
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 92 deletions.
2 changes: 1 addition & 1 deletion src/actions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @flow */

import type {Feature, FeatureState, FeatureAction} from './index.js.flow'
import type {Feature, FeatureState, FeatureAction} from './index'

export const ACTION_TYPE_PREFIX = '@@redux-features/'
export const ADD_FEATURE = ACTION_TYPE_PREFIX + 'ADD_FEATURE'
Expand Down
2 changes: 1 addition & 1 deletion src/featureReducersReducer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow

import type {Reducer} from 'redux'
import type {Features, ComposeReducers} from './index.js.flow'
import type {Features, ComposeReducers} from './index'
import {createSelector} from 'reselect'

import {defaultComposeReducers} from './defaults'
Expand Down
4 changes: 1 addition & 3 deletions src/featureStatesReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import {ADD_FEATURE, LOAD_FEATURE, INSTALL_FEATURE, REPLACE_FEATURE, SET_FEATURE_STATE, LOAD_INITIAL_FEATURES} from './actions'
import { mapValues } from "lodash"
import type {Reducer} from 'redux'
import type {FeatureStates, FeatureAction, CreateReducer} from './index.js.flow'
import type {FeatureStates, FeatureAction, CreateReducer} from './index'

import {defaultCreateReducer} from './defaults'

Expand All @@ -22,5 +22,3 @@ export default function featureStatesReducer(
[LOAD_INITIAL_FEATURES]: state => mapValues(state, fs => fs === 'LOADED' ? 'LOADING' : fs)
})
}


4 changes: 1 addition & 3 deletions src/featuresReducer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow

import type {Reducer} from 'redux'
import type {Features, FeatureAction, CreateReducer} from './index.js.flow'
import type {Features, FeatureAction, CreateReducer} from './index'
import {ADD_FEATURE, INSTALL_FEATURE, REPLACE_FEATURE} from './actions'

import {defaultCreateReducer} from './defaults'
Expand All @@ -19,5 +19,3 @@ export default function featuresReducer<S, A: {type: $Subtype<string>}>(
[REPLACE_FEATURE]: (state, {payload, meta: {id}}) => state[id] ? {...state, [id]: payload} : state,
})
}


34 changes: 34 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,37 @@ export {
addFeature, loadFeature, installFeature, replaceFeature, setFeatureState, loadInitialFeatures,
}

import type {MiddlewareAPI, Reducer, Middleware, ActionCreator} from 'redux'

/*
S = State
A = Action
*/

export type ActionCreators<K, A> = { [key: K]: ActionCreator<A> }

export type CreateReducer<S, A> =
(<S, A: {type: $Subtype<string>}>(initialState: S, reducers: {[actionType: string]: Reducer<S, A>}) => Reducer<S, A>) &
(<S, A: {type: $Subtype<string>}>(reducers: {[actionType: string]: Reducer<S, A>}) => Reducer<S, A>)
export type ComposeReducers<S, A> = (...reducers: Array<Reducer<S, A>>) => Reducer<S, A>
export type ComposeMiddleware<S, A> = (...middlewares: Array<Middleware<S, A>>) => Middleware<S, A>

export type FeatureState = 'NOT_LOADED' | 'LOADING' | 'LOADED' | Error
export type FeatureStates = {[featureId: string]: FeatureState}

export type Feature<S, A> = {
init?: (store: MiddlewareAPI<S, A>) => any,
load?: (store: MiddlewareAPI<S, A>) => Promise<Feature<S, A>>,
dependencies?: Array<string>,
middleware?: Middleware<S, A>,
reducer?: Reducer<S, A>,
}
export type Features<S, A> = {[featureId: string]: Feature<S, A>}

export type FeatureAction = {
type: string,
payload?: any,
meta?: {id: string},
}
81 changes: 0 additions & 81 deletions src/index.js.flow

This file was deleted.

4 changes: 1 addition & 3 deletions src/loadFeatureMiddleware.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import type {Feature, Features, FeatureStates, FeatureAction} from './index.js.flow'
import type {Feature, Features, FeatureStates, FeatureAction} from './index'
import type {Middleware, MiddlewareAPI, Dispatch} from 'redux'
import {ADD_FEATURE, LOAD_FEATURE, installFeature, setFeatureState, LOAD_INITIAL_FEATURES, loadFeature} from './actions'
import {defaultCreateMiddleware} from './defaults'
Expand Down Expand Up @@ -77,5 +77,3 @@ export default function loadFeatureMiddleware<S, A: {type: $Subtype<string>}>(
},
})
}


0 comments on commit ad09127

Please sign in to comment.