Need private packages and team management tools?Check out npm Teams »

alt-dom-events

1.0.0 • Public • Published

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

Keywords

Install

npm i alt-dom-events

DownloadsWeekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • avatar