protected function listen(DataProvider $provider)
    {
        Event::listen(
            DataProvider::EVENT_FETCH_ROW,
            function (DataRow $row, DataProvider $currentProvider) use ($provider) {
                if ($currentProvider !== $provider) return;
                $this->rows_processed++;
                foreach ($this->fields as $field) {
                    $name = $field->getName();
                    $operation = $this->getFieldOperation($name);
                    switch($operation) {

                        case self::OPERATION_SUM:
                            $this->src[$name] += $row->getCellValue($field);
                            break;
                        case self::OPERATION_COUNT:
                            $this->src[$name] = $this->rows_processed;
                            break;
                        case self::OPERATION_AVG:
                            $key = "{$name}_sum";
                            if (empty($this->src[$key])) {
                                $this->src[$key] = 0;
                            }
                            $this->src[$key] += $row->getCellValue($field);
                            $this->src[$name] = round(
                                $this->src[$key] / $this->rows_processed,
                                2
                            );
                            break;
                        default:
                            throw new LogicException(
                                'TotalsRow: Unknown aggregation operation.'
                            );
                    }

                }

            }
        );
    }