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

The following examples show how to use com.taobao.weex.common.WXModule#isOnce() . 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);
      }
    }
  }
}