Message from JavaScript discussions

December 2016

— It's a type of companion factory to the main store factory, which adds actions to the stores as callbacks instead of switched blocks

Message permanent page


Making an action looks like...

// Deselect an item
deselect: storeObjects.FileBrowser.addAction(function (resolve, reject, state, idnum) {
state.itemEntryContainer.contents[idnum].selected = false;
}, true),

— Resolving the promise returns the modified state to the store, which runs it's update function

— A nice side effect is efficient error handling :)

— Http://

— That factory is included inside the main datastore factory like so:

addAction: function (callback, update) {
return actionFactory(opcode, callback, update);

Message permanent page

— It also bypasses the store's input processor by default, since the state being returned should already be processed

Message permanent page

— Also, it has the option of creating 2 different action types: updating and non-updating. Both get state, only one pushes it back to the store

Message permanent page

— The response not same in the two cases

— The update case revive the promise resolve and reject

— And the false case only data

— It's confused for me create and resolve the promise in the same position