topicSubscribe static method

void topicSubscribe(
  1. List<String> params,
  2. dynamic onSuccess(
    1. List<Topic> topic
    )?,
  3. dynamic onError(
    1. ErrorModel error
    )?
)

Subscribe to Topics

topics Array of Topics to subscribe Callback to get Topic's list Throw ErrorModel if there is some error during the processs

Implementation

static void topicSubscribe(
    List<String> params,
    Function(List<Topic> topic)? onSuccess,
    Function(ErrorModel error)? onError) async {
  _indigitall
      .invokeMapMethod(_ACTION_TOPICS_SUBSCRIBE, params)
      .then((value) => {
            if (value != null)
              {
                value.forEach((key, valueMap) {
                  if (key == _CALLBACK_TOPIC_SUBSCRIBE) {
                    if (onSuccess != null)
                      onSuccess(Topic.createArray(valueMap));
                  }
                })
              }
          })
      .catchError((error) => {
            if (error is PlatformException)
              {
                if (onError != null)
                  onError(ErrorModel(error.code, error.message))
              }
          });
}