Skip to content

Commit ad09127

Browse files
committed
fix: index flow type exports
1 parent 57fc104 commit ad09127

File tree

7 files changed

+39
-92
lines changed

7 files changed

+39
-92
lines changed

src/actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

3-
import type {Feature, FeatureState, FeatureAction} from './index.js.flow'
3+
import type {Feature, FeatureState, FeatureAction} from './index'
44

55
export const ACTION_TYPE_PREFIX = '@@redux-features/'
66
export const ADD_FEATURE = ACTION_TYPE_PREFIX + 'ADD_FEATURE'

src/featureReducersReducer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22

33
import type {Reducer} from 'redux'
4-
import type {Features, ComposeReducers} from './index.js.flow'
4+
import type {Features, ComposeReducers} from './index'
55
import {createSelector} from 'reselect'
66

77
import {defaultComposeReducers} from './defaults'

src/featureStatesReducer.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import {ADD_FEATURE, LOAD_FEATURE, INSTALL_FEATURE, REPLACE_FEATURE, SET_FEATURE_STATE, LOAD_INITIAL_FEATURES} from './actions'
44
import { mapValues } from "lodash"
55
import type {Reducer} from 'redux'
6-
import type {FeatureStates, FeatureAction, CreateReducer} from './index.js.flow'
6+
import type {FeatureStates, FeatureAction, CreateReducer} from './index'
77

88
import {defaultCreateReducer} from './defaults'
99

@@ -22,5 +22,3 @@ export default function featureStatesReducer(
2222
[LOAD_INITIAL_FEATURES]: state => mapValues(state, fs => fs === 'LOADED' ? 'LOADING' : fs)
2323
})
2424
}
25-
26-

src/featuresReducer.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22

33
import type {Reducer} from 'redux'
4-
import type {Features, FeatureAction, CreateReducer} from './index.js.flow'
4+
import type {Features, FeatureAction, CreateReducer} from './index'
55
import {ADD_FEATURE, INSTALL_FEATURE, REPLACE_FEATURE} from './actions'
66

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

src/index.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,37 @@ export {
2424
addFeature, loadFeature, installFeature, replaceFeature, setFeatureState, loadInitialFeatures,
2525
}
2626

27+
import type {MiddlewareAPI, Reducer, Middleware, ActionCreator} from 'redux'
28+
29+
/*
30+
31+
S = State
32+
A = Action
33+
34+
*/
35+
36+
export type ActionCreators<K, A> = { [key: K]: ActionCreator<A> }
37+
38+
export type CreateReducer<S, A> =
39+
(<S, A: {type: $Subtype<string>}>(initialState: S, reducers: {[actionType: string]: Reducer<S, A>}) => Reducer<S, A>) &
40+
(<S, A: {type: $Subtype<string>}>(reducers: {[actionType: string]: Reducer<S, A>}) => Reducer<S, A>)
41+
export type ComposeReducers<S, A> = (...reducers: Array<Reducer<S, A>>) => Reducer<S, A>
42+
export type ComposeMiddleware<S, A> = (...middlewares: Array<Middleware<S, A>>) => Middleware<S, A>
43+
44+
export type FeatureState = 'NOT_LOADED' | 'LOADING' | 'LOADED' | Error
45+
export type FeatureStates = {[featureId: string]: FeatureState}
46+
47+
export type Feature<S, A> = {
48+
init?: (store: MiddlewareAPI<S, A>) => any,
49+
load?: (store: MiddlewareAPI<S, A>) => Promise<Feature<S, A>>,
50+
dependencies?: Array<string>,
51+
middleware?: Middleware<S, A>,
52+
reducer?: Reducer<S, A>,
53+
}
54+
export type Features<S, A> = {[featureId: string]: Feature<S, A>}
55+
56+
export type FeatureAction = {
57+
type: string,
58+
payload?: any,
59+
meta?: {id: string},
60+
}

src/index.js.flow

Lines changed: 0 additions & 81 deletions
This file was deleted.

src/loadFeatureMiddleware.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @flow
22

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

0 commit comments

Comments
 (0)