react-native-admob / admob

Admob for React Native with powerful hooks and components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Thoughts about architecture

Mikenso opened this issue · comments

Hey, thanks for your efforts

Just want to reveal some thoughts about your logical decisions.

Moving all logic into hooks significantly reduces the developer's ability to manage ads in their application. For example I would want to start load interstitial on start and show it inside few different screens depending of what user would open, so I would move adv logic in my app to redux-sagas (for example) and dispatch "show actions" when I need, check if enough time has gone since previous interstitial and etc
So you literally overcoded. It would be better to just have ability to load / show / listen events ( loaded, error, etc). And leave the ability to developers make their own hooks

Hey @Mikenso
Actually this library give the ability to load interstitial with and without hooks, everything is well described in the doc:
https://react-native-admob.github.io/admob/docs/api/InterstitialAd

@magrinj this doesn't seem to work, if you try to call InterstitialAd.createAd(TestIds.INTERSTITIAL) the app crashes with this error

RCTCallableJSModules is not set. This is probably because you've explicitly synthesized the RCTCallableJSModules in RNAdMobEvent, even though it's inherited from RCTEventEmitter

Hi, thank you for your opinion.
Firstly, the hooks introduced in this library doesn't do many things any other than you said: such as loading, showing, and listening to events and export derived value according to the events.

Options provided for the hooks such as showOnLoaded or loadOnDismissed are for those who use ads for not-complex scenario, for them, those options would lessen workload for implementing further code. If you don't need the options, you could set the option values to false to opt out any logic I have implemented.

And also if you need more customize behavior, you could just implement your logic without using the hooks but using class instances as @magrinj referenced.