react-native-background-timer icon indicating copy to clipboard operation
react-native-background-timer copied to clipboard

Improvement in Export Method as "export default BackgroundTimer()"

Open Louies89 opened this issue 6 years ago • 0 comments

Hi, Instead of using export as export default new BackgroundTimer() in index.js, if it shall be done like export default BackgroundTimer(), only one global instance of BackgroundTimer shall be created for the app.

Although there is no effect on memory usage(as per my knowledge) in both the way of exporting, one advantage shall be there in export default BackgroundTimer(). The advantage is, as the BackgroundTimer instance is same in complete application, we can start a timer in one component and clear it in another component by passing the timeoutId/intervalId.

And if needed new BackgroundTimer() can be used to create different instances.

Let me know, if I am wrong somewhere.

Louies89 avatar Oct 08 '18 11:10 Louies89