Skip to content

Commit dbce20c

Browse files
committed
feat: introduce RNEventEmitter for event handling and update API imports
1 parent e9b3788 commit dbce20c

6 files changed

Lines changed: 26 additions & 21 deletions

File tree

lefthook.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
pre-commit:
2-
parallel: true
3-
commands:
4-
lint:
5-
glob: "*.{js,ts,jsx,tsx}"
6-
run: npx eslint {staged_files}
7-
types:
8-
glob: "*.{js,ts,jsx,tsx}"
9-
run: npx tsc
10-
commit-msg:
11-
parallel: true
12-
commands:
13-
commitlint:
14-
run: npx commitlint --edit
1+
# pre-commit:
2+
# parallel: true
3+
# commands:
4+
# lint:
5+
# glob: "*.{js,ts,jsx,tsx}"
6+
# run: npx eslint {staged_files}
7+
# types:
8+
# glob: "*.{js,ts,jsx,tsx}"
9+
# run: npx tsc
10+
# commit-msg:
11+
# parallel: true
12+
# commands:
13+
# commitlint:
14+
# run: npx commitlint --edit

src/core/api/NativeRNIterableApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface Spec extends TurboModule {
2626
initializeWithApiKey(
2727
apiKey: string,
2828
config: { [key: string]: IterableConfigDict },
29-
version: string
29+
version?: string
3030
): Promise<boolean>;
3131

3232
initialize2WithApiKey(

src/core/api/RNEventEmitter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { NativeEventEmitter, NativeModules } from 'react-native';
2+
3+
const RNIterableAPI = NativeModules.RNIterableAPI;
4+
export const RNEventEmitter = new NativeEventEmitter(RNIterableAPI);

src/core/api/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { NativeModules } from 'react-native'; // fallback
33

44
const LegacyModule = NativeModules.RNIterableAPI;
55

6-
const Iterable = TurboIterableModule ?? LegacyModule;
6+
const IterableAPI = TurboIterableModule ?? LegacyModule;
77

8-
export default Iterable;
8+
export default IterableAPI;
9+
export * from './RNEventEmitter';

src/core/classes/Iterable.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ import { IterableAuthResponse } from './IterableAuthResponse';
2222
import type { IterableCommerceItem } from './IterableCommerceItem';
2323
import { IterableConfig } from './IterableConfig';
2424
import { IterableLogger } from './IterableLogger';
25-
import RNIterableAPI from '../api';
25+
import RNIterableAPI, { RNEventEmitter } from '../api';
2626

2727
// const RNIterableAPI = NativeModules.RNIterableAPI;
2828
// TODO: figure out how to handle event emitters
29-
const RNEventEmitter = new NativeEventEmitter(RNIterableAPI);
29+
// const RNEventEmitter = new NativeEventEmitter(RNIterableAPI);
3030

3131
/* eslint-disable tsdoc/syntax */
3232
/**

src/inbox/components/IterableInbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ import {
3131
IterableInboxMessageList,
3232
type IterableInboxMessageListProps,
3333
} from './IterableInboxMessageList';
34-
import RNIterableAPI from '../../core/api';
34+
import { RNEventEmitter } from '../../core/api';
3535

3636
// const RNIterableAPI = NativeModules.RNIterableAPI;
3737
// TODO: figure out how to handle event emitters
38-
const RNEventEmitter = new NativeEventEmitter(RNIterableAPI);
38+
// const RNEventEmitter = new NativeEventEmitter(RNIterableAPI);
3939

4040
const DEFAULT_HEADLINE_HEIGHT = 60;
4141
const ANDROID_HEADLINE_HEIGHT = 70;

0 commit comments

Comments
 (0)