state property

Stream<AppKitState> get state

Listens to the AppKit state.

Implementation

static Stream<AppKitState> get state {
  late StreamController<AppKitState> controller;
  late Function? stopListeningFunction;

  void startListening() {
    stopListeningFunction = window.appkit
        .subscribeState(
          ((PublicStateControllerState state) {
            controller.add(state.toDart);
          }).toJS,
        )
        .toDart;
  }

  void stopListening() {
    stopListeningFunction?.call();
    stopListeningFunction = null;
  }

  controller = StreamController<AppKitState>(
    onListen: startListening,
    onPause: stopListening,
    onResume: startListening,
    onCancel: stopListening,
  );

  return controller.stream;
}