subscribeToEvent function Null safety
Subscribes to global Event such as 'pageLoaded', with a callback
function
Implementation
int subscribeToEvent(String eventName, Function(Event) callback) {
var event = Event(eventName, callback, '', 0);
if(!simpleEvents.containsKey(eventName)){
simpleEvents[eventName] = List<Event>.empty(growable: true);
}
simpleEvents[eventName] ??= List<Event>.empty(growable: true);
simpleEvents[eventName]?.add(event);
var length = simpleEvents[eventName]?.length;
length ??= 0;
return length - 1;
}