addCall method

void addCall(
  1. AliceHttpCall call
)

Add alice http call to calls subject

Implementation

void addCall(AliceHttpCall call) {
  final callsCount = callsSubject.value.length;
  if (callsCount >= maxCallsCount) {
    final originalCalls = callsSubject.value;
    final calls = List<AliceHttpCall>.from(originalCalls)
      ..sort(
        (call1, call2) => call1.createdTime.compareTo(call2.createdTime),
      );
    final indexToReplace = originalCalls.indexOf(calls.first);
    originalCalls[indexToReplace] = call;

    callsSubject.add(originalCalls);
  } else {
    callsSubject.add([...callsSubject.value, call]);
  }
}