Class ChannelExtensionsKt

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final static <T extends Any> Channel<T> bufferedChannel() This method creates a buffered Channel suitable for use in a single time event use case.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • bufferedChannel

        @RestrictTo(value = {RestrictTo.Scope.LIBRARY_GROUP}) final static <T extends Any> Channel<T> bufferedChannel()

        This method creates a buffered Channel suitable for use in a single time event use case.

        Being a Channel, the values emitted behave as events (as opposed to state) which means if an observer re-observes the channel, they will NOT receive a value that they already collected earlier.

        Another advantage is that the producer can send values to the Channel even if no consumer is observing it.

        In theory we should be able to replace this with MutableSharedFlow but it didn't work in practice because the MutableSharedFlow.tryEmit method does not work as expected, meaning that emitted values will be silently lost if the flow has no observers at the moment the values are emitted.