function dispatch({method, params}) {
      // Get live listeners in case they change.
      const eventListeners = on.mock.calls.filter(call => call[0] === method).map(call => call[1]);
      for (const listener of eventListeners) {
        listener(params);
      }

      const starListeners = on.mock.calls.filter(call => call[0] === '*').map(call => call[1]);
      for (const listener of starListeners) {
        listener(method, params);
      }
    }
@param {{method: string, params: unknown}} args