GREMLIN.JS dispatcher mixin.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
src
test
.babelrc
.eslintrc
.gitignore
.npmignore
LICENSE
README.md
gulpfile.js
package.json

README.md

gremlins-dispatcher

gremlin.js dispatcher mixin. Easy component interoperability.

Installation

requires gremlins@1.1.x

NPM

$ npm install gremlins-dispatcher

Usage

At the moment, all listeners will be called, even if the component is not added to the visual dom

<listener-gremlin>
</listener-gremlin>

<dispatcher-gremlin>
</dispatcher-gremlin>
const gremlins = require('gremlins');
const dispatcher = require('gremlins-dispatcher');
  
gremlins.create('listener-gremlin', {
    mixins: [dispatcher],
    getListeners(){
        return {
          'FOO': 'onFoo'
        };
    },
    onFoo(data) {
        console.log(data.foo);
    }
});  

gremlins.create('dispatcher-gremlin', {
    mixins: [dispatcher],

    ...

    someAction(){
      this.emit('FOO', {
        foo: 'foo'
      });
    }
});

TODO

  • add some sort of queue to have a consistent state across all components, even if they are not created yet.