Closed x1B closed 8 years ago
(draft changelog comment removed)
Implemented on master
(v2.0.0
) and master-1.x
(v1.3.0
).
There is a new method connectPublisherToFeature( context, featurePath )
which creates an action publisher for the given feature and adds that publisher function as a property to the given context's actions
object, under the corresponding path, creating the object as needed.
If the given action feature is not configured for a widget instance, the function is still created, but as a no-op. The new method is intended to simplify creating widgets where actions should be triggered directly from a widget template.
First, let's assume that we are writing a widget that has feature configuration for a doStuff.action
(so, it acts as an outlet for that action):
Widget Controller:
patterns.actions.connectPublisherToFeature($scope, 'doStuff');
Widget Template
<button ng-click="actions.doStuff()">click me</button>
<button ng-click="actions.doStuff({ myPayload: [] })">click me, with payload</button>
Widget Component
patterns.actions.connectPublisherToFeature(context, 'doStuff');
// ...
axReactRender(
<div>
<button onClick={context.actions.doStuff}></button>
<button onClick={ () => context.actions.doStuff({ myPayload: [] }) } >
click me, with payload
</button>
</div>
)
When writing unidirectional dataflow apps with LaxarJS, it would be handy to have action publishers automatically be registered under
axContext.actions
(similar toresources
, but in the opposite direction).