Skip to content
This repository was archived by the owner on Mar 13, 2023. It is now read-only.

feat: log warnings when Sovran native module is missing... #43

Merged
merged 1 commit into from
Oct 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,19 @@ const LINKING_ERROR =
'- You rebuilt the app after installing the package\n' +
'- You are not using Expo managed workflow\n';

const Sovran = NativeModules.Sovran
? NativeModules.Sovran
: new Proxy(
{},
{
get() {
throw new Error(LINKING_ERROR);
},
}
);
const Sovran = NativeModules.Sovran;
if (Sovran) {
const { ON_STORE_ACTION } = Sovran.getConstants();

const { ON_STORE_ACTION } = Sovran.getConstants();

const SovranBridge = new NativeEventEmitter(Sovran);

// Listen to Native events
SovranBridge.addListener(ON_STORE_ACTION, (event) => {
onStoreAction(event.type, event.payload);
});
const SovranBridge = new NativeEventEmitter(Sovran);

// Listen to Native events
SovranBridge.addListener(ON_STORE_ACTION, (event) => {
onStoreAction(event.type, event.payload);
});
} else {
console.warn(LINKING_ERROR);
}
export { createStore, Store, Notify, Unsubscribe } from './store';
export { registerBridgeStore } from './bridge';
export * from './persistor';