Event Bus question - F7 version 7

Considering the example in the documentation, can someone please tell me where the event bus needs to be created?

// Where does this go?
const notificationEvents = new Framework7.Events();

//This in receiving part of app
notificationEvents.on('notificationReceived', function (notification) {
  // do something with notification
})

//This in sending part of app
notificationEvents.emit('notificationReceived', {
  title: 'New message',
  from: 'John Doe',
});

I usually put custom code like yours, initialization or other helper functions in app-methods.js and include that right after Framework7 scripts at the end of the body:

  ...
	<!-- Framework7 library -->
	<script src="framework7/framework7-bundle.min.js"></script>
	<!-- Cordova APIs -->
	<script src="js/cordova-app.js"></script>

	<script src="js/app-methods.js"></script>
	<!-- App routes -->
	<script src="js/routes.js"></script>
	<!-- App store -->
	<script src="js/store.js"></script>
	<!-- App scripts -->
	<script src="js/app.js"></script>
    </body>
</html>
1 Like