subscribeToChannel method

TivioDataStream<TivioDataChannel>? subscribeToChannel({
  1. required String channelId,
})

Implementation

TivioDataStream<TivioDataChannel>? subscribeToChannel({required String channelId}) {
  var controller = TivioDataStreamController<TivioDataChannel>();
  var callFunctionWithArguments = () => callFunction('subscribeToChannel', [channelId], (payload) => null, errorPayload: CallFunctionErrorPayload(messageId: 'subscribe-to-channel:$channelId', type: 'callback'));

  _callbackMessageBroker.listen('subscribe-to-channel:$channelId', (payload) {
    handleNewEventInStream(payload, controller, callFunctionWithArguments, (payload) => TivioDataChannel.fromJson(payload));
  });

  callFunctionWithArguments();

  return controller.tivioDataStream;
}