0.0.2 • Published 9 years ago
ember-wormhole-action v0.0.2
Ember Wormhole Action
Nearly always state in an Ember application should be managed by following the 'data down, actions up' paradigm. However there are some rare cases where it is reasonable to send actions sideways. Ember wormhole action provides provides a clean interface for doing so.
Installation
ember install ember-wormhole-action
Usage
- Make a component wormhole actionable using
mixin:wormhole-actionable - Use
helper:wormhole-actionto send an action sideways
mixin:wormhole-actionable
To make an action on a component wormhole actionable (1) mixin the
wormhole-actionable mixin and (2) define a wormholeActionableActions
property on the class.
wormholeActionableActions should be an array of POJO's each of which
defines action and name properties.
actionis the action defined in the componentnameis what becomes 'wormhole actionable' and should be less generically named thanaction
import Ember from 'ember';
import WormholeActionable from 'ember-wormhole-action/mixins/wormhole-actionable';
export default Ember.Component.extend(WormholeActionable, {
wormholeActionableActions: [
{action: 'open', name: 'openDrawer'}
],
actions: {
open(item) {
// ...
}
}
});helper:wormhole-action
Use the helper to call a wormhole actionable action. Note that
wormhole-action will accept params to pass to the action.
<button onClick={{wormhole-action 'openDrawer' item}}>Open</button>0.0.2
9 years ago