subscribeToContentCards method

StreamSubscription subscribeToContentCards(
  1. void onEvent(
    1. List<BrazeContentCard>
    )
)

Subscribes to the stream of content cards and calls onEvent when it receives the list of content cards.

Implementation

StreamSubscription subscribeToContentCards(
    void Function(List<BrazeContentCard>) onEvent) {
  if (_replayCallbacksConfigEnabled() && _queuedContentCards.isNotEmpty) {
    print(
        "Replaying stream onEvent for previously queued Braze content cards.");
    onEvent(_queuedContentCards);
    _queuedContentCards.clear();
  }

  StreamSubscription subscription =
      contentCardsStreamController.stream.listen(onEvent);
  return subscription;
}