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 localParams = _stripReq(params);
  return beforeIndexed
      ._emit(HookedServiceEvent(false, _getRequest(params),
          _getResponse(params), inner, HookedServiceEvent.indexed,
          params: localParams))
      .then((before) {
    if (before._canceled) {
      return afterIndexed
          ._emit(HookedServiceEvent(true, _getRequest(params),
              _getResponse(params), inner, HookedServiceEvent.indexed,
              params: localParams, result: before.result))
          .then((after) => after.result as List<Data>);
    }

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