subscribe method
Registers a callback
to listen for the specified event topic
.
Returns true
if the callback was added, false
if it was already added.
Implementation
bool subscribe(String topic, Function callback) {
if (!_cache.containsKey(topic)) {
_cache[topic] = [];
}
if (!_cache[topic]!.contains(callback)) {
_cache[topic]!.add(callback);
return true;
}
return false;
}