Skip to content

Commit

Permalink
release v2.0.0-alpha.22
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Dec 31, 2023
1 parent d17e506 commit 2bbba7d
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 27 deletions.
30 changes: 24 additions & 6 deletions packages/core/Libraries/vendor/emitter/_EventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import EventSubscriptionVendor from './_EventSubscriptionVendor';
* mechanism on top of which extra functionality can be composed. For example, a
* more advanced emitter may use an EventHolder and EventFactory.
*/

let isFirstEventFired = false;
export default class EventEmitter {
/**
* The JSModuleInvoker in JSModules() will be indexing into EventEmitter to
Expand Down Expand Up @@ -130,13 +132,29 @@ export default class EventEmitter {
*
* emitter.emit('someEvent', 'abc'); // logs 'abc'
*/

emit(eventType: string, ...args: unknown[]): void {
this._subscriber
.getSubscriptionsForType(eventType)
.forEach((subscription) =>
// The subscription may have been removed during this event loop.
subscription?.listener.apply(subscription.context, args)
);
if (!isFirstEventFired) {
// Since this can be called from native, we don't want to dispatch immediately on first load since
// we are probably not done setting up listeners yet (possibly) as JS & Native are running on the
// same thread.
setTimeout(() => {
isFirstEventFired = true;
this._subscriber
.getSubscriptionsForType(eventType)
.forEach((subscription) =>
// The subscription may have been removed during this event loop.
subscription?.listener.apply(subscription.context, args)
);
}, 0);
} else {
this._subscriber
.getSubscriptionsForType(eventType)
.forEach((subscription) =>
// The subscription may have been removed during this event loop.
subscription?.listener.apply(subscription.context, args)
);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package-for-npm.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@open-native/core",
"version": "2.0.0-alpha.19",
"version": "2.0.0-alpha.22",
"description": "Open Native helps cross platform communities work better together.",
"main": "index",
"types": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@open-native/core",
"version": "2.0.0-alpha.19",
"version": "2.0.0-alpha.22",
"description": "Open Native helps cross platform communities work better together.",
"main": "index",
"types": "index.d.ts",
Expand Down
18 changes: 6 additions & 12 deletions packages/core/src/android/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ export function getJSModules() {

function emit(eventType, params) {
const data = toJSValue(params);
setTimeout(() => {
DeviceEventEmitter.emit(eventType, data);
}, 1);
DeviceEventEmitter.emit(eventType, data);
}

function RCTDeviceEventEmitter() {
Expand All @@ -40,9 +38,7 @@ function RCTNativeAppEventEmitter() {
return new com.facebook.react.modules.core.RCTNativeAppEventEmitter({
emit(eventType, params) {
const data = toJSValue(params);
setTimeout(() => {
DeviceEventEmitter.emit(eventType, data);
}, 1);
DeviceEventEmitter.emit(eventType, data);
},
});
}
Expand All @@ -56,12 +52,10 @@ function RCTEventEmitter() {
},
receiveEvent(viewTag, eventName, params) {
const data = toJSValue(params);
setTimeout(() => {
const view = viewRegistry[viewTag];
if (view) {
view.receiveEvent(eventName, data);
}
}, 1);
const view = viewRegistry[viewTag];
if (view) {
view.receiveEvent(eventName, data);
}
},
});
}
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/ios/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ export function invokeNativeMethod(
return promisify.call(this, invocation, types, args);
}
const nativeArguments = toNativeArguments(types, args);
console.log(nativeArguments.arguments);
return reactNativeBridgeIOS.callMethodInvocationArgsTypesSyncRRIRejRejICbCbIEEI(
invocation,
nativeArguments.arguments,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/ios/viewmanagers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export function requireNativeViewIOS<T extends keyof ViewManagerInterfaces>(
if (NATIVE_VIEW_CACHE[key as string]) return NATIVE_VIEW_CACHE[key as string];

(NATIVE_VIEW_CACHE[key as string] = class extends FlexboxLayout {
nativeProps: { [name: string]: any[] } = {};
nativeProps: { [name: string]: any } = {};
_viewTag: number;
_viewManager = viewManager;
_viewEventRecievers: {
Expand Down
22 changes: 17 additions & 5 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"target": "ES2020",
"module": "ESNext",
"jsx": "react-native",
"lib": ["ESNext", "dom"],
"lib": [
"ESNext",
"dom"
],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"baseUrl": ".",
Expand All @@ -21,10 +24,19 @@
}
],
"paths": {
"@demo/shared": ["tools/demo/index.ts"],
"@open-native/core": ["packages/core/index.d.ts"],
"react-native-module-test": ["packages/react-native-module-test/index.d.ts"]
"@demo/shared": [
"tools/demo/index.ts"
],
"@open-native/core": [
"packages/core/index.d.ts"
],
"react-native-module-test": [
"packages/react-native-module-test/index.d.ts"
],
}
},
"exclude": ["node_modules", "tmp"]
"exclude": [
"node_modules",
"tmp"
]
}

0 comments on commit 2bbba7d

Please sign in to comment.