setSdkStateListener method

  1. @override
Stream<MoveState> setSdkStateListener()
override

Set a block to be invoked every time SDK state changes. Important:

  • Set this State listener before initializing the SDK to anticipate the SDK State changes triggered by initializing API.

Returns stream: latest SDK state. Invoked every time SDK state changes.

Implementation

@override
Stream<MoveState> setSdkStateListener() async* {
  yield* sdkStateChannel
      .receiveBroadcastStream()
      .asyncMap<MoveState>((sdkState) {
    MoveState? result = MoveState.values.firstWhereOrNull(
        (element) => element.name.toLowerCase() == sdkState.toLowerCase());
    return result ?? MoveState.unknown;
  });
}