package com.device.comm.mylibrary;


import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule;

import javax.annotation.Nullable;

/**
 * Created by mac on 15/12/23.
 */
public class KOJNativeEventManager extends ReactContextBaseJavaModule {

//    private static KOJNativeEventManager myInstance;
    public KOJNativeEventManager(ReactApplicationContext reactContext) {
        super(reactContext);


    }


    /** 发送事件 */
    public void sendCustomEvent(String eventName,
                                @Nullable Object params) {
        sendEvent(getReactApplicationContext(), eventName, params);
    }


    @Override
    public String getName() {
        return "KOJNativeEventManager";
    }

    private void sendEvent(ReactContext reactContext,
                           String eventName,
                           @Nullable Object params) {
        reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
                .emit(eventName, params);
    }
}
