本文整理汇总了Java中com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter方法的典型用法代码示例。如果您正苦于以下问题:Java DeviceEventManagerModule.RCTDeviceEventEmitter方法的具体用法?Java DeviceEventManagerModule.RCTDeviceEventEmitter怎么用?Java DeviceEventManagerModule.RCTDeviceEventEmitter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.react.modules.core.DeviceEventManagerModule
的用法示例。
在下文中一共展示了DeviceEventManagerModule.RCTDeviceEventEmitter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SendEvent
import com.facebook.react.modules.core.DeviceEventManagerModule; //导入方法依赖的package包/类
public void SendEvent(String eventName, Object... args) {
WritableArray argsList = Arguments.createArray();
for (Object arg : args) {
if (arg == null)
argsList.pushNull();
else if (arg instanceof Boolean)
argsList.pushBoolean((Boolean)arg);
else if (arg instanceof Integer)
argsList.pushInt((Integer)arg);
else if (arg instanceof Double)
argsList.pushDouble((Double)arg);
else if (arg instanceof String)
argsList.pushString((String)arg);
else if (arg instanceof WritableArray)
argsList.pushArray((WritableArray)arg);
else {
//Assert(arg instanceof WritableMap, "Event args must be one of: WritableArray, Boolean")
if (!(arg instanceof WritableMap))
throw new RuntimeException("Event args must be one of: Boolean, Integer, Double, String, WritableArray, WritableMap");
argsList.pushMap((WritableMap)arg);
}
}
DeviceEventManagerModule.RCTDeviceEventEmitter jsModuleEventEmitter = reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
jsModuleEventEmitter.emit(eventName, argsList);
}
示例2: getEventEmitter
import com.facebook.react.modules.core.DeviceEventManagerModule; //导入方法依赖的package包/类
private DeviceEventManagerModule.RCTDeviceEventEmitter getEventEmitter() {
return getReactApplicationContext()
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
}
示例3: getEventEmitter
import com.facebook.react.modules.core.DeviceEventManagerModule; //导入方法依赖的package包/类
private DeviceEventManagerModule.RCTDeviceEventEmitter getEventEmitter(ExecutorToken ExecutorToken) {
return getReactApplicationContext()
.getJSModule(ExecutorToken, DeviceEventManagerModule.RCTDeviceEventEmitter.class);
}
示例4: emit
import com.facebook.react.modules.core.DeviceEventManagerModule; //导入方法依赖的package包/类
/**
* Emits a device event to JavaScript.
* @param eventName the event name.
* @param payload the payload.
*/
void emit(final String eventName, final WritableMap payload) {
DeviceEventManagerModule.RCTDeviceEventEmitter jsModule =
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
jsModule.emit(eventName, payload);
}