import nativeEventer from '../../common/nativeEventer';
import messager from '../../common/messager';

const TOPIC_NAME = 'observer.emit';
const TOPIC_EMIT = 'deliverMsg';
const eventer = new nativeEventer({ topic: TOPIC_NAME });

export default {
  on(topic, callback) {
    return eventer.on(topic, callback);
  },

  off(topic, callback) {
    return eventer.off(topic, callback);
  },

  emit(event, message) {
    return messager.dispatch(TOPIC_EMIT, { event, message });
  },
}
