How to use mitt - 10 common examples

To help you get started, we’ve selected a few mitt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github brocessing / copilote / src / controllers / map / map.js View on Github external
/* global THREE */

import mitt from 'mitt'
import store from 'utils/store'
import config from 'config'
import prng from 'utils/prng'

const emitter = mitt()
const DISTVIEW = config.viewDistance // chunk side
const CHUNKSIZE = config.chunkSize

const CHUNKDISTFROMCENTER = (DISTVIEW - 1) / 2
const CHUNKCENTER = CHUNKSIZE / 2 + 0.5
// const WALKMAPCENTER = CHUNKSIZE * ((DISTVIEW - 1) / 2) + (CHUNKSIZE - 1) / 2
let chunksPool = []
let currentMiddleChunk = null
let loadedChunks = {}
let walkMap = []
let prevPos = [0, 0]

let domDebug
if (config.locDebug) {
  domDebug = document.createElement('pre')
  domDebug.style.zIndex = 10000
github CartoDB / carto-vl / src / Layer.js View on Github external
});

        /* Custom Layer API attributes:
          - id: string
          - type: "custom"
        */
        this.id = id;
        this.type = 'custom';

        this.metadata = null;
        this._state = 'init';
        this._visible = true;
        this._isLoaded = false;
        this._matrix = null;
        this._fireUpdateOnNextRender = false;
        this._emitter = mitt();
        this._oldDataframes = new Set();
        this._renderLayer = new RenderLayer();
        this._atomicChangeUID = 0;

        this.update(source, viz);
    }
github regularjs / regular-devtools / src / devtools-ui / agent.js View on Github external
constructor() {
        Object.assign(this, mitt());

        port.onMessage.addListener(message => {
            switch (message.type) {
            case 'dataUpdate':
                this.emit('dataUpdate');
                break;
            case 'reRender':
                this.emit('reRender', message.nodes);
                break;
            case 'initNodes':
                this.emit('initNodes', message.nodes);
                break;
            case 'currNodeChange':
                this.emit('currNodeChange', message.uuid);
                break;
            case 'pageReload':
github hoschi / yode / packages / demo / src / plugin / emitter.js View on Github external
import mitt from 'mitt'

const emitter = mitt()

export const emitterMiddleware = store => next => action => {
    let result = next(action)
    emitter.emit(action.type, {
        state: store.getState(),
        action
    })
    return result
}

export default emitter
github JimmyVV / iv-panorama / src / lib / repo / orientation / src / index.js View on Github external
constructor() {

        if(!this.isSupport){
            console.warn('Your browser don\'t support orientation API ');
            return;
        }

        window.addEventListener('deviceorientation', this._control.bind(this), false);

        this._emitter = new Mitt();

        this._deviceProp = {
            start: {},
            first: true
        }
    }
    get isSupport() {
github suchipi / react-send / src / index.js View on Github external
const Component = require("react").Component;
let mitt = require("mitt");
if (mitt.default) {
  mitt = mitt.default;
}

module.exports = function send(name = "Send") {
  let emitter = mitt();

  class Input extends Component {
    static displayName = `${name}.Input`;

    componentDidMount() {
      emitter.emit("update", this.props.children);
    }

    componentDidUpdate() {
      emitter.emit("update", this.props.children);
    }
github suchipi / react-send / src / index.js View on Github external
const Component = require("react").Component;
let mitt = require("mitt");
if (mitt.default) {
  mitt = mitt.default;
}

module.exports = function send(name = "Send") {
  let emitter = mitt();

  class Input extends Component {
    static displayName = `${name}.Input`;

    componentDidMount() {
      emitter.emit("update", this.props.children);
    }

    componentDidUpdate() {
      emitter.emit("update", this.props.children);
    }
github barrel / promobar / index.js View on Github external
export default (root, opts = {}) => {

  /**
   * Emitter
   */
  const events = mitt()

  /**
   * Merge options with defaults
   */
  const config = merge({
    content: (root.querySelector('.js-content') || root).innerHTML,
    resize: true,
    placeholder: true,
    offsets: [],
    close: Array.prototype.slice.call(document.querySelectorAll('.js-promobarClose')),
    lifespan: 1
  }, opts)

  if (!config.content){ return error.content() }

  /**
github camwest / react-slot-fill / src / lib / components / Provider.ts View on Github external
constructor() {
    super();
    this._bus = new mitt();
    this._manager = new Manager(this._bus);
    this._manager.mount();
  }
github qiscus / qiscus-sdk-web-core / src / lib / adapters / sync.js View on Github external
function synchronizeFactory (getHttp, getInterval, getSync, getId, logger) {
  const emitter = mitt()
  const synchronize = messageId => {
    const url = UrlBuilder('api/v2/sdk/sync')
      .param('last_received_comment_id', messageId)
      .build()

    return getHttp()
      .get(url)
      .then(resp => {
        const results = resp.body.results
        const messages = results.comments
        const lastMessageId = results.meta.last_received_comment_id
        messages.sort((a, b) => a.id - b.id)
        return Promise.resolve({
          lastMessageId,
          messages,
          interval: getInterval()

mitt

Tiny 200b functional Event Emitter / pubsub.

MIT
Latest version published 1 year ago

Package Health Score

73 / 100
Full package analysis

Popular mitt functions