Skip to content

Commit

Permalink
Trigger non-fired events when JS bridge is up
Browse files Browse the repository at this point in the history
  • Loading branch information
manuquentin committed May 28, 2020
1 parent 48c6b88 commit 875cd6e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const checkReachability = handler =>
const didLoadWithEvents = handler =>
eventEmitter.addListener(RNCallKeepDidLoadWithEvents, handler);

export const emit = (eventName, payload) => eventEmitter.emit(eventName, payload);

export const listeners = {
didReceiveStartCallAction,
answerCall,
Expand All @@ -71,5 +73,5 @@ export const listeners = {
didPerformDTMFAction,
didResetProvider,
checkReachability,
didLoadWithEvents
didLoadWithEvents,
};
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NativeModules, Platform, Alert } from 'react-native';

import { listeners } from './actions'
import { listeners, emit } from './actions'

const RNCallKeepModule = NativeModules.RNCallKeep;
const isIOS = Platform.OS === 'ios';
Expand All @@ -22,6 +22,12 @@ class RNCallKeep {

constructor() {
this._callkeepEventHandlers = new Map();

this.addEventListener('didLoadWithEvents', (events) => {
events.forEach(event => {
emit(evemt.name, event.data);
});
});
}

addEventListener = (type, handler) => {
Expand Down
1 change: 0 additions & 1 deletion ios/RNCallKeep/RNCallKeep.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ @implementation RNCallKeep
BOOL _isStartCallActionEventListenerAdded;
bool _hasListeners;
NSMutableArray *_delayedEvents;

}

static CXProvider* sharedProvider;
Expand Down

0 comments on commit 875cd6e

Please sign in to comment.