Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
fix flow errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Aug 2, 2016
1 parent 00fd966 commit 740cfd4
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ node_modules
test
testlib
spec
.babelrc
.eslintrc
.flowconfig
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-plugins-immutable",
"version": "1.2.0",
"version": "1.2.1",
"description": "a powerful app plugin system for redux using immutable state",
"main": "lib/index.js",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions src/pluginActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export const LOAD_PLUGIN = 'LOAD_PLUGIN'
export const INSTALL_PLUGIN = 'INSTALL_PLUGIN'
export const SET_PLUGIN_STATUS = 'SET_PLUGIN_STATUS'

export function addPlugin(plugin: Immutable.Collection): Action {
export function addPlugin(plugin: Immutable.Collection<any, any>): Action {
return {
type: ADD_PLUGIN,
payload: plugin
}
}

export function replacePlugin(plugin: Immutable.Collection): Action {
export function replacePlugin(plugin: Immutable.Collection<any, any>): Action {
return {
type: REPLACE_PLUGIN,
payload: plugin
Expand All @@ -31,7 +31,7 @@ export function loadPlugin(key: string): Action {
}
}

export function installPlugin(plugin: Immutable.Collection): Action {
export function installPlugin(plugin: Immutable.Collection<any, any>): Action {
return {
type: INSTALL_PLUGIN,
payload: plugin
Expand Down
2 changes: 1 addition & 1 deletion src/pluginMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const addPluginHandler: Middleware = store => next => action => {
let pluginWasAdded = plugin.get('pluginWasAdded')
pluginWasAdded && pluginWasAdded(store)
}

return result
}

Expand Down
12 changes: 6 additions & 6 deletions src/pluginReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {Action, Reducer} from './reduxTypes'

import {LOADED, NOT_LOADED} from './pluginTypes'

const selectPluginReducers: (state: Immutable.Map) => Reducer = createSelector(
const selectPluginReducers: (state: Immutable.Map<any, any>) => Reducer = createSelector(
state => state.get('plugins'),
plugins => (plugins ?
composeReducers(...plugins.map(p => p.get('reducer')).toArray()) :
Expand All @@ -21,7 +21,7 @@ const selectPluginReducers: (state: Immutable.Map) => Reducer = createSelector(

const pluginReducer: Reducer = composeReducers(
createReducer({
[ADD_PLUGIN]: (state: Immutable.Map, action: Action) => {
[ADD_PLUGIN]: (state: Immutable.Map<any, any>, action: Action) => {
let plugin = action.payload
warning(plugin instanceof Immutable.Map, 'plugin must be an Immutable.Map')
if (!(plugin instanceof Immutable.Map)) {
Expand All @@ -37,7 +37,7 @@ const pluginReducer: Reducer = composeReducers(
return existing || plugin.update('loadStatus', loadStatus => loadStatus || NOT_LOADED)
})
},
[REPLACE_PLUGIN]: (state: Immutable.Map, action: Action) => {
[REPLACE_PLUGIN]: (state: Immutable.Map<any, any>, action: Action) => {
let plugin = action.payload
warning(plugin instanceof Immutable.Map, 'plugin must be an Immutable.Map')
if (!(plugin instanceof Immutable.Map)) {
Expand All @@ -53,7 +53,7 @@ const pluginReducer: Reducer = composeReducers(
return existing && plugin.update('loadStatus', loadStatus => loadStatus || NOT_LOADED)
})
},
[INSTALL_PLUGIN]: (state: Immutable.Map, action: Action) => {
[INSTALL_PLUGIN]: (state: Immutable.Map<any, any>, action: Action) => {
let plugin = action.payload
warning(plugin instanceof Immutable.Map, 'plugin must be an Immutable.Map')
if (!(plugin instanceof Immutable.Map)) {
Expand All @@ -69,7 +69,7 @@ const pluginReducer: Reducer = composeReducers(
return result.set('loadStatus', LOADED).delete('loadError')
})
},
[SET_PLUGIN_STATUS]: (state: Immutable.Map, action: Action) => {
[SET_PLUGIN_STATUS]: (state: Immutable.Map<any, any>, action: Action) => {
let {meta: {key}, payload: {loadStatus, loadError}} = action
return state.updateIn(['plugins', key], plugin => {
warning(plugin, 'missing plugin for key: %s', key)
Expand All @@ -88,7 +88,7 @@ const pluginReducer: Reducer = composeReducers(
}
}),
// apply the plugins' reducers
(state: Immutable.Map, action: Action) => selectPluginReducers(state)(state, action)
(state: Immutable.Map<any, any>, action: Action) => selectPluginReducers(state)(state, action)
)

export default pluginReducer
4 changes: 2 additions & 2 deletions test/pluginMiddlewareTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('pluginMiddleware', () => {
store.actions = actions
return store
}

describe('addPluginHandler', () => {
it('calls pluginWasAdded iff it exists after plugin was added', done => {
const initialState = Immutable.Map({plugins: Immutable.Map()})
Expand All @@ -29,7 +29,7 @@ describe('pluginMiddleware', () => {
expect(store.getState instanceof Function).toBe(true)
done()
}
})
})
store.dispatch(addPlugin(plugin))
})
})
Expand Down
3 changes: 2 additions & 1 deletion test/pluginReducerTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ describe('pluginReducer', () => {
plugins: {
p1: {
key: 'p1',
name: 'Plugin 1'
name: 'Plugin 1',
loadStatus: LOADED
}
}
})
Expand Down

0 comments on commit 740cfd4

Please sign in to comment.