jcperez-ch / flaxs

const Flaxs = Flux + Redux.principles();
BSD 3-Clause "New" or "Revised" License
2 stars 2 forks source link

Allow the creation of synchronous actions #13

Closed jcperez-ch closed 8 years ago

jcperez-ch commented 8 years ago

Fixes issue https://github.com/jcperez-ch/flaxs/issues/9 by adding a second parameter to allow synchronous dispatching, now we can assure that action invocations and master store changes are synchronized by creating our actions like:

let mockSyncActionsFactory = flaxs.createActions({
    add: function(item) {
      return {
        actionType: TestConstants.TEST_ADD,
        item,
      }
    },
    remove: function(item) {
      return {
        actionType: TestConstants.TEST_REMOVE,
        item,
      }
    }
  }, false
);

The first parameter of flaxs.createActions is still the object with callback definitions and the second parameter is a boolean (by default true) that flags the actions as asynchronous if true.