Summary: *Stack summary*: this stack refactors plugin management actions to perform them in a dispatcher rather than in the root reducer (store.tsx) as all of these actions has side effects. To do that, we store requested plugin management actions (install/update/uninstall, star/unstar) in a queue which is then handled by pluginManager dispatcher. This dispatcher then dispatches all required state updates. *Diff summary*: refactored "star plugin" operation to perform it in pluginManager dispatcher. Reviewed By: mweststrate Differential Revision: D26305576 fbshipit-source-id: 90516af4e9ba8504720ddfa587f691f53e71b702
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import {createStore} from 'redux';
|
|
import reducers, {Actions, State as StoreState, Store} from './reducers/index';
|
|
import {stateSanitizer} from './utils/reduxDevToolsConfig';
|
|
import isProduction from './utils/isProduction';
|
|
import {_SandyPluginDefinition} from 'flipper-plugin';
|
|
export const store: Store = createStore<StoreState, Actions, any, any>(
|
|
rootReducer,
|
|
// @ts-ignore Type definition mismatch
|
|
window.__REDUX_DEVTOOLS_EXTENSION__
|
|
? window.__REDUX_DEVTOOLS_EXTENSION__({
|
|
// @ts-ignore: stateSanitizer is not part of type definition.
|
|
stateSanitizer,
|
|
})
|
|
: undefined,
|
|
);
|
|
|
|
export function rootReducer(
|
|
state: StoreState | undefined,
|
|
action: Actions,
|
|
): StoreState {
|
|
return reducers(state, action);
|
|
}
|
|
|
|
if (!isProduction()) {
|
|
// For debugging purposes only
|
|
// @ts-ignore
|
|
window.flipperStore = store;
|
|
}
|