Closed EPNW-Eric closed 1 year ago
Thanks for the clarification about FutureOr
😊.
Thanks for the contribution! 👍
dispatchActions
is of typeFutureOr
because of the signature of the_dequeue
method which itself is of this type because we are only returning an instance ofFuture
(withreturn _lock.synchronized()
) if the process is not locked. For_dequeue
to be aFuture
we'd have to make the methodasync
which was deemed unneeded as we don't need to use theawait
keyword.
I just found https://dart.dev/effective-dart/design#avoid-using-futureort-as-a-return-type, and I think it might be a good idea to follow this, but I don't know how to apply that here in a way that there are now unintended side effects with locking...
@EPNW-Eric I agree that following Dart guidelines should be the way to go, I'll do the appropriate refactor to change that
I added
dropActions
to manually clear the dispatch queue.I also renamed
dispatchEvents
todispatchActions
, because technically, those are actions and not only events (events are a subtype of actions) and I wanted to lower the confusion potential by using the correct Matomo nomenclature.Also, can someone explain why the return type of (now)
dispatchActions
and_dequeue
isFutureOr
and not simplyFuture
?