Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const pluginFactory: () => RPCPluginType = () =>
createPlugin({
deps: {
fetch: FetchToken,
emitter: UniversalEventsToken,
i18n: I18nToken.optional,
rpcConfig: RPCHandlersConfigToken.optional,
},
provides: deps => {
const {fetch = window.fetch, emitter, rpcConfig, i18n} = deps;
return {
from: ctx => {
const locale = (i18n && i18n.from(ctx).locale) || '';
const localeCode = typeof locale === 'string' ? locale : locale.code;
return new RPC({
fetch,
emitter,
rpcConfig,
localeCode,
});
},