Skip to content

Commit

Permalink
new arch. support for ios and android config (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
ug-dev authored Jun 20, 2023
1 parent 12bb50a commit 571e6c1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@
"devDependencies": {
"@babel/core": "^7.12.9",
"@react-native-community/eslint-config": "^2.0.0",
"@types/react-native": "^0.64.8",
"@types/react-native": "^0.68.0",
"babel-jest": "^26.1.0",
"eslint": "^7.32.0",
"eslint-plugin-prettier": "^3.1.2",
"jest": "^26.1.0",
"metro-react-native-babel-preset": "^0.64.0",
"prettier": "^2.4.1",
"react": "17.0.1",
"react-native": "0.64.1",
"react-native": "0.68.0",
"react-native-macos": "^0.62.0-0",
"react-native-windows": "^0.64.0",
"react-test-renderer": "16.9.0",
Expand All @@ -67,5 +67,13 @@
},
"publishConfig": {
"access": "public"
},
"codegenConfig": {
"name": "RNCClipboard",
"type": "all",
"jsSrcsDir": ".",
"android": {
"javaPackageName": "com.reactnativecommunity.clipboard"
}
}
}
}
20 changes: 11 additions & 9 deletions src/NativeClipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ import {
NativeModules,
NativeEventEmitter,
EmitterSubscription,
TurboModuleRegistry,
} from 'react-native';
import type { TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';

// Separated file for Native Clipboard to be ready to switch to Turbo Module when it becomes public
// TODO: uncomment when Turbo module is available
// export interface Spec extends TurboModule {
// +getConstants: () => {||};
// +getString: () => Promise<string>;
// +setString: (content: string) => void;
// +hasString: () => Promise<boolean>;
// }
export interface Spec extends TurboModule {
getConstants: () => {};
getString: () => Promise<string>;
setString: (content: string) => void;
hasString: () => Promise<boolean>;
}

export default NativeModules.RNCClipboard;
export default TurboModuleRegistry.get<Spec>(
'RNCClipboard'
) as Spec | null;

const EVENT_NAME = 'RNCClipboard_TEXT_CHANGED';
const eventEmitter = new NativeEventEmitter(NativeModules.RNCClipboard);
Expand Down

0 comments on commit 571e6c1

Please sign in to comment.