-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: eliminates require cycles, and some unused code (#39)
* Enables "no-undef" ESLint rule, cleans up related issues * Removes "statics" from GoogleAdsModule config I am quite sure, it wasn't used anywhere in the code * Gets rid of require cycles * The link to CONTRIBUTING in PR template was wrong
- Loading branch information
1 parent
c53c657
commit 323c400
Showing
10 changed files
with
58 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
src/version.js | ||
lib/version.js | ||
**/node_modules/** | ||
node_modules | ||
scripts/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Module } from './internal'; | ||
import validateAdRequestConfiguration from './validateAdRequestConfiguration'; | ||
import version from './version'; | ||
|
||
const namespace = 'google_ads'; | ||
|
||
const nativeModuleName = [ | ||
'RNGoogleAdsModule', | ||
'RNGoogleAdsInterstitialModule', | ||
'RNGoogleAdsRewardedModule', | ||
]; | ||
|
||
class GoogleAdsModule extends Module { | ||
constructor(...args) { | ||
super(...args); | ||
|
||
this.emitter.addListener('google_ads_interstitial_event', event => { | ||
this.emitter.emit( | ||
`google_ads_interstitial_event:${event.adUnitId}:${event.requestId}`, | ||
event, | ||
); | ||
}); | ||
|
||
this.emitter.addListener('google_ads_rewarded_event', event => { | ||
this.emitter.emit(`google_ads_rewarded_event:${event.adUnitId}:${event.requestId}`, event); | ||
}); | ||
} | ||
|
||
setRequestConfiguration(requestConfiguration) { | ||
let config; | ||
try { | ||
config = validateAdRequestConfiguration(requestConfiguration); | ||
} catch (e) { | ||
throw new Error(`googleAds.setRequestConfiguration(*) ${e.message}`); | ||
} | ||
|
||
return this.native.setRequestConfiguration(config); | ||
} | ||
} | ||
|
||
const googleMobileAds = new GoogleAdsModule('AppName', { | ||
version, | ||
namespace, | ||
nativeModuleName, | ||
nativeEvents: ['google_ads_interstitial_event', 'google_ads_rewarded_event'], | ||
}); | ||
|
||
export default () => { | ||
return googleMobileAds; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters