Summary: This adds an optional exit strategy that reacts to the client disconnecting rather than a `SIGINT` which can be used for integration tests. `MiddlewareAPI` is a subset of `Store` and required to work here. Annoyingly, it's not quite clear to me why this does not work as part of an event loop cycle and requires a `setTimeout`. This doesn't have any negative effects and works in the same way that the SIGINT interruption works, but it's a bit of an eyesore. Reviewed By: danielbuechele Differential Revision: D14622111 fbshipit-source-id: e2caca056e478428d977565dc9bc09eefca4230c
98 lines
2.2 KiB
JavaScript
98 lines
2.2 KiB
JavaScript
/**
|
|
* Copyright 2018-present Facebook.
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
* @format
|
|
*/
|
|
|
|
import {combineReducers} from 'redux';
|
|
import application from './application.js';
|
|
import connections from './connections.js';
|
|
import pluginStates from './pluginStates.js';
|
|
import notifications from './notifications.js';
|
|
import plugins from './plugins.js';
|
|
import user from './user.js';
|
|
|
|
import {persistReducer} from 'redux-persist';
|
|
import storage from 'redux-persist/lib/storage/index.js';
|
|
|
|
import type {
|
|
State as ApplicationState,
|
|
Action as ApplicationAction,
|
|
} from './application.js';
|
|
import type {
|
|
State as DevicesState,
|
|
Action as DevicesAction,
|
|
} from './connections.js';
|
|
import type {
|
|
State as PluginStatesState,
|
|
Action as PluginStatesAction,
|
|
} from './pluginStates.js';
|
|
import type {
|
|
State as NotificationsState,
|
|
Action as NotificationsAction,
|
|
} from './notifications.js';
|
|
import type {
|
|
State as PluginsState,
|
|
Action as PluginsAction,
|
|
} from './plugins.js';
|
|
import type {State as UserState, Action as UserAction} from './user.js';
|
|
import type {
|
|
Store as ReduxStore,
|
|
MiddlewareAPI as ReduxMiddlewareAPI,
|
|
} from 'redux';
|
|
|
|
type Actions =
|
|
| ApplicationAction
|
|
| DevicesAction
|
|
| PluginStatesAction
|
|
| NotificationsAction
|
|
| PluginsAction
|
|
| UserAction
|
|
| {|type: 'INIT'|};
|
|
|
|
export type State = {|
|
|
application: ApplicationState,
|
|
connections: DevicesState,
|
|
pluginStates: PluginStatesState,
|
|
notifications: NotificationsState,
|
|
plugins: PluginsState,
|
|
user: UserState,
|
|
|};
|
|
|
|
export type Store = ReduxStore<State, Actions>;
|
|
export type MiddlewareAPI = ReduxMiddlewareAPI<State, Actions>;
|
|
|
|
export default combineReducers<_, Actions>({
|
|
application,
|
|
connections: persistReducer(
|
|
{
|
|
key: 'connections',
|
|
storage,
|
|
whitelist: [
|
|
'userPreferredDevice',
|
|
'userPreferredPlugin',
|
|
'userPreferredApp',
|
|
],
|
|
},
|
|
connections,
|
|
),
|
|
pluginStates,
|
|
notifications: persistReducer(
|
|
{
|
|
key: 'notifications',
|
|
storage,
|
|
whitelist: ['blacklistedPlugins', 'blacklistedCategories'],
|
|
},
|
|
notifications,
|
|
),
|
|
plugins,
|
|
user: persistReducer(
|
|
{
|
|
key: 'user',
|
|
storage,
|
|
},
|
|
user,
|
|
),
|
|
});
|