deb-horizon/releasenotes/notes/action-results-303c282165b60f47.yaml
Tyr Johanson 6192bfd7ac Images tables uses action promises
This patch demonstrates how promises returned by actions are
used by the images table. In particular, notice how specific
action event handlers do not need to be registered. This
allows a view to support a wide variety of actions without
needing to setup a specific event listener for each type of
event the action might emit.

One could argue that if action events were standardized, they
could still be used, which is true. Consider a generic SUCCESS
event. However, promises have additional benefits and avoid
some of the problems of events.

One advantage is that promises make it easy to "chain" multiple
handlers to a single success or failure. For example, once ALL
of these actions have completed successfully, then update a status
icon. We see another example of this in the delete-action.service
which uses a promise chain to convert the data returned by the
delete-modal.service into a standardized form used by actions.

Also, promises don't require that the caller have a parent scope.
In angular, events "bubble" from child scope to the parent
scope. These scopes are effectively the view hierarchy, where
a panel contains a table, which contains rows, which contain
buttons. However, actions are not view elements lke a table or
input box. Actions, like "delete image" are a behavior
that may be invoked independently, and the code that cares about
the success or failure of that action may not be a scope parent.

Added an action-result service that provides a convenience object
for creating such results.

Co-Authored-By: Matt Borland <matt.borland@hpe.com>

Partially-Implements: blueprint angular-registry
Change-Id: Id6725664e5654a4f75508993b9640a0de80c6884
2016-05-05 14:06:18 -06:00

13 lines
434 B
YAML

---
prelude: >
Angular actions now should return a promise
that resolves with an object structured in a way
to indicate what the action did (or didn't do).
features:
- An action-result service provides convenience methods
for construction of the result, and for parsing of
a resolved object
upgrade:
- Although it's not required, it's best to make your
actions return promises with the expected structure.