Deal with Flux architecture example
RefluxJS.
In Manet the library describes two methods for asynchronous actions:
someAction.completed
someAction.failed
If I understand correctly, they are called (or should be called) in case of success and failure of an asynchronous task.
They need to hang the methods of storage to handle the results or they are needed to intercept logging failures?
Treatment outcome and failure can be done directly in the storage:
var asyncAction = Reflux.createAction({});
var someStore = Reflux.createStore({
data: [],
init: function () {
this.listenTo(asyncAction, this.onAsyncAction);
},
onAsyncAction: function () {
myAsyncWorker()
.success(this.storeNewData)
.error(this.asyncErrorHandler)
.complete(function () {
this.trigger({
data: this.data
});
});
},
storeNewData: function (data) {
//todo something with data and store it
},
asyncErrorHandler: function (error) {
//todo something with error
}
});
And this is without additional method steps (completed, failed).
What is the idea and the subtlety of the creation and use of an additional method to the action (completed, failed)?
- arlene_Lebsa commented on September 19th 19 at 00:25