Skip to content

Commit

Permalink
emptymodule
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnylqm committed Apr 22, 2024
1 parent e9e67b0 commit 9fd6293
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
import { EmptyModule, log } from './utils';
import { emptyModule, log } from './utils';
const {
version: v,
} = require('react-native/Libraries/Core/ReactNativeVersion');
Expand All @@ -10,7 +10,7 @@ const isTurboModuleEnabled =

export const PushyModule =
Platform.OS === 'web'
? new EmptyModule()
? emptyModule
: isTurboModuleEnabled
? require('./NativePushy').default
: NativeModules.Pushy;
Expand Down
4 changes: 2 additions & 2 deletions src/permissions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PermissionsAndroidStatic } from 'react-native';
import { EmptyModule } from './utils';
import { emptyModule } from './utils';

export const PermissionsAndroid = new EmptyModule() as PermissionsAndroidStatic;
export const PermissionsAndroid = emptyModule as PermissionsAndroidStatic;
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function log(...args: any[]) {
}

const noop = () => {};
export class EmptyModule {
class EmptyModule {
constructor() {
return new Proxy(this, {
get() {
Expand All @@ -14,6 +14,7 @@ export class EmptyModule {
});
}
}
export const emptyModule = new EmptyModule();

const ping =
Platform.OS === 'web'
Expand Down

0 comments on commit 9fd6293

Please sign in to comment.