Java Code Examples for com.taobao.weex.common.WXModule#getEventCallbacks()

The following examples show how to use com.taobao.weex.common.WXModule#getEventCallbacks() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WXSDKInstance.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
/**
 * Notifies WEEX that this event has occurred
 * @param eventName WEEX register event
 * @param module Events occur in this Module
 * @param params The parameters to be notified to WEEX are required
 */
public void fireModuleEvent(String eventName, WXModule module,Map<String, Object> params) {
  if (TextUtils.isEmpty(eventName) || module == null) {
    return;
  }

  Map<String, Object> event = new HashMap<>();
  event.put("type", eventName);
  event.put("module", module.getModuleName());
  event.put("data", params);

  List<String> callbacks = module.getEventCallbacks(eventName);
  if (callbacks != null) {
    for (String callback : callbacks) {
      SimpleJSCallback jsCallback = new SimpleJSCallback(mInstanceId, callback);
      if (module.isOnce(callback)) {
        jsCallback.invoke(event);
      } else {
        jsCallback.invokeAndKeepAlive(event);
      }
    }
  }
}
 
Example 2
Source File: WXSDKInstance.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
 * Notifies WEEX that this event has occurred
 * @param eventName WEEX register event
 * @param module Events occur in this Module
 * @param params The parameters to be notified to WEEX are required
 */
public void fireModuleEvent(String eventName, WXModule module,Map<String, Object> params) {
  if (TextUtils.isEmpty(eventName) || module == null) {
    return;
  }
  List<String> callbacks = module.getEventCallbacks(eventName);
  if (callbacks != null) {
    for (String callback : callbacks) {
      SimpleJSCallback jsCallback = new SimpleJSCallback(mInstanceId, callback);
      if (module.isOnce(callback)) {
        jsCallback.invokeAndKeepAlive(params);
      } else {
        jsCallback.invoke(params);
      }
    }
  }
}
 
Example 3
Source File: WXSDKInstance.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
/**
 * Check whether the current module registered the event
 * @param eventName EventName register in weex
 * @param module Events occur in this Module
 * @return  register->true
 */
public boolean checkModuleEventRegistered(String eventName,WXModule module) {
  if (module != null) {
    List<String> events = module.getEventCallbacks(eventName);
    if (events != null && events.size() > 0) {
      return true;
    }
  }
  return false;
}
 
Example 4
Source File: WXSDKInstance.java    From weex-uikit with MIT License 5 votes vote down vote up
/**
 * Check whether the current module registered the event
 * @param eventName EventName register in weex
 * @param module Events occur in this Module
 * @return  register->true
 */
public boolean checkModuleEventRegistered(String eventName,WXModule module) {
  if (module != null) {
    List<String> events = module.getEventCallbacks(eventName);
    if (events != null && events.size() > 0) {
      return true;
    }
  }
  return false;
}