1.0.0 • Published 7 years ago

alt-dom-events v1.0.0

Weekly downloads
9
License
MIT
Repository
github
Last release
7 years ago

alt-dom-events Build Status

dom events support for alt

bindDOMEvents

Binds events fired on document to Alt actions, e.g.

import alt from './alt';
import {bindDOMEvents} from 'alt-dom-events';

class FooActions {
  constructor() {
    this.generateActions('foo', 'bar');
  }
}

export default bindDOMEvents({ 
  'foo-document-event': 'foo',
  'bar-document-event': 'bar'
}, alt.createActions(FooActions));

The following fires action FooActions.foo when foo-document-event is dispatched

document.dispatchEvent(new CustomEvent('foo-document-event', { detail: {}}));

ES7 decorator

bindDOMEvents can be used as a decorator

import alt from './alt';
import {createActions} from 'alt-utils/lib/decorators';
import {bindDOMEvents} from 'alt-dom-events';

@bindDOMEvents({
  'foo-document-event': 'foo',
  'bar-document-event': 'bar'
})
@createActions(alt)
class FooActions {
  constructor() {
    this.generateActions('foo', 'bar');
  }
}

export default FooActions;

License

MIT

1.0.0

7 years ago

0.2.0

8 years ago

0.1.0

8 years ago