once method
Registers a callback to listen for the specified event topic
.
The callback
will only be called once for this event.
Returns true
if the callback was added, false
if it was already added.
Implementation
bool once(String topic, Function callback) {
if (!_cacheOnce.containsKey(topic)) {
_cacheOnce[topic] = [];
}
if (!_cacheOnce[topic]!.contains(callback)) {
_cacheOnce[topic]!.add(callback);
return true;
}
return false;
}