index method

  1. @override
Future<List<Data>> index([
  1. Map<String, dynamic>? _params
])
override

Retrieves all resources.

Implementation

@override
Future<List<Data>> index([Map<String, dynamic>? _params]) {
  var params = _stripReq(_params);
  return beforeIndexed
      ._emit(HookedServiceEvent(false, _getRequest(_params),
          _getResponse(_params), inner, HookedServiceEvent.indexed,
          params: params))
      .then((before) {
    if (before._canceled) {
      return afterIndexed
          ._emit(HookedServiceEvent(true, _getRequest(_params),
              _getResponse(_params), inner, HookedServiceEvent.indexed,
              params: params, result: before.result))
          .then((after) => after.result as List<Data>);
    }

    return inner.index(params).then((result) {
      return afterIndexed
          ._emit(HookedServiceEvent(true, _getRequest(_params),
              _getResponse(_params), inner, HookedServiceEvent.indexed,
              params: params, result: result))
          .then((after) => after.result as List<Data>);
    });
  });
}