Video optimizations (#18)
* use events for `VideoTrackRenderer` * logger * implemented visibility detection * optimize code with 1 param debounce func * stop pending visibility event when disposed * clean up * mark internal * report to track * call dispose on pub and track * use internal events to receive visibility events * clean up visibility for disposed track * listen to track visibility events on pub * re-design * quickly re-enable * clean up * clean up
This commit is contained in:
+5
-5
@@ -138,18 +138,18 @@ class Utils {
|
||||
];
|
||||
}
|
||||
|
||||
// makes a debounce func
|
||||
static Function createDebounceFunc(
|
||||
Function f, {
|
||||
// makes a debounce func, with 1 param
|
||||
static Function(T) createDebounceFunc<T>(
|
||||
Function(T) f, {
|
||||
Function(Function)? cancelFunc,
|
||||
required Duration wait,
|
||||
}) {
|
||||
Timer? t;
|
||||
return () {
|
||||
return (p) {
|
||||
t?.cancel();
|
||||
t = Timer(wait, () {
|
||||
t = null;
|
||||
f();
|
||||
f(p);
|
||||
});
|
||||
// pass back the cancel method so we can cancel it when no longer needed
|
||||
cancelFunc?.call(t!.cancel);
|
||||
|
||||
Reference in New Issue
Block a user