No Description

index.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import {
  2. NativeModules,
  3. findNodeHandle,
  4. NativeAppEventEmitter
  5. } from 'react-native';
  6. const { Agora } = NativeModules
  7. export default {
  8. init(options = {}) {
  9. this.listener && this.listener.remove();
  10. Agora.init(options);
  11. },
  12. joinChannel(channelName = '001'){
  13. Agora.joinChannel(channelName)
  14. },
  15. eventEmitter(fnConf) {
  16. // const {
  17. // onFirstRemoteVideoDecoded = () => {},
  18. // onJoinChannelSuccess = () => {},
  19. // onUserJoined = () => {},
  20. // onError = () => {},
  21. // onWarning = () => {}
  22. // } = options;
  23. // let fnConf = {...options};
  24. //there are no `removeListener` for NativeAppEventEmitter & DeviceEventEmitter
  25. this.listener && this.listener.remove();
  26. this.listener = NativeAppEventEmitter.addListener('agoraEvent', event => {
  27. fnConf[event['type']] && fnConf[event['type']](event);
  28. });
  29. },
  30. removeEmitter() {
  31. this.listener && this.listener.remove();
  32. }
  33. };