debugAttachStateEngine function

  1. @visibleForTesting
void Function() debugAttachStateEngine(
  1. void emit(
    1. String kind,
    2. Map<String, Object?> payload
    )
)

Sends the state.* events of the stores registered from now on, and of those already, to emit, as if a Capybara server were connected: for the tests of adapter packages. The function returned stops it.

Implementation

@visibleForTesting
void Function() debugAttachStateEngine(void Function(String kind, Map<String, Object?> payload) emit) {
  final engine = StateEngine((kind, payload, {ts}) => emit(kind, payload), connected: () => true);
  StateRegistry.instance.attach(engine);
  return () {
    StateRegistry.instance.detach(engine);
    engine.dispose();
  };
}