alt-dom-events
v1.0.0
Published
dom events support for alt
Downloads
2
Readme
alt-dom-events
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