Kill onRegisterDevice

Summary: `onRegisterDevice` device abstraction was only used by the CrashReporterPlugin, and since with Sandy plugin lifecycles every plugin can do 'on-load' logic, we don't need it anymore.

Reviewed By: priteshrnandgaonkar

Differential Revision: D27046711

fbshipit-source-id: 16c567c60ed29a50017d525a2b707ee696a99e62
This commit is contained in:
Michel Weststrate
2021-03-16 14:54:53 -07:00
committed by Facebook GitHub Bot
parent 87c5fab607
commit 6a30899803
5 changed files with 0 additions and 85 deletions

View File

@@ -1,52 +0,0 @@
/**
* 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 type {Store} from '../reducers/index';
import type {
ClientPluginMap,
DevicePluginMap,
PluginDefinition,
} from '../plugin';
import {setPluginState} from '../reducers/pluginStates';
import type BaseDevice from '../devices/BaseDevice';
import {getPersistedState, isSandyPlugin} from '../utils/pluginUtils';
export function registerDeviceCallbackOnPlugins(
store: Store,
devicePlugins: DevicePluginMap,
clientPlugins: ClientPluginMap,
device: BaseDevice,
) {
const callRegisterDeviceHook = (plugin: PluginDefinition) => {
// This hook is not registered for Sandy plugins, let's see in the future if it is needed
if (!isSandyPlugin(plugin) && plugin.onRegisterDevice) {
plugin.onRegisterDevice(
store,
device,
(pluginKey: string, newPluginState: any) => {
const persistedState = getPersistedState(
pluginKey,
plugin,
store.getState().pluginStates,
);
if (newPluginState && newPluginState !== persistedState) {
store.dispatch(
setPluginState({
pluginKey,
state: newPluginState,
}),
);
}
},
);
}
};
devicePlugins.forEach(callRegisterDeviceHook);
clientPlugins.forEach(callRegisterDeviceHook);
}