Tags:
- [New Feature]
- [Bug Fix]
- [Breaking Change]
- [Documentation]
- [Internal]
- [Polish]
- New Feature
- Multiple handlers can be registered for the same action.
- Async action handlers are sent a
dispatchId
as part of the payload. The dispatch id for abegin
dispatch is equal to the id of the correspondingsuccess
orerror
dispatch. This enables fine-grained optimistic updates. Store#registerMatch(matcher, handler)
calls a handler when the matcher function returns true for a dispatched payload. The handler is passed the payload.- Use
injectActions
prop of FluxComponent to pass actions to children as props. - Actions no longer warn if they aren't added to a Flux instance.
- FluxComponent supports injecting actions as props, in the same vein as
connectToStores
. - Use
stores
andactions
props interchangeably withconnectToStores
andinjectActions
. - connectToStores HoC now supports actions as well and is just called connect.
- Returning an object from a store handler now does an implicit state update by passing that object to
setState
. This lets you treat store handlers like reducer functions. To accommodate this usage, the previous state is passed as the final parameter (after the payload).
- Breaking Change
- Removal of Actions class. Instead, pass a plain JavaScript object of functions.
- The arguments passed to async action handlers have been changed. The final argument passed to any action handler is the raw payload that is sent through the dispatcher. For example, "begin" handlers receive the payload as its sole argument.
- Arguments sent to the
render
prop function of FluxComponent have been changed:render(storeState, actions, flux)
. Notably, extra props added to FluxComponent are no longer combined with storeState, andflux
is a separate parameter as well. - Changed interface to HoC to support actions.
- fluxMixin has been removed.
- Flux instance prop is no longer automatically passed as prop to children of FluxComponent
- Full support for React Native, including addons (FluxComponent, connect, etc.)
- Internal
- Cleaned up Store's
register
methods. Much simpler code paths now.
- Cleaned up Store's
- Bug Fix
registerAll(action, handler)
is effectively the same asregisterAllAsync(action, null, handler, null)
@hugobessaa
- Bug Fix
- Higher-order component wasn't passing through props @Blitz2145
- New Feature
Flux#createActions()
will now also accept a plain JavaScript object instead of an Actions class.
- New Feature
removeActions()
andremoveStore()
@chicoxyzzy
- Bug Fix
- Squash Chrome
Uncaught (in promise) errors
once and for all (hopefully). Big thanks to @johanneslumpe.
- Squash Chrome
- Bug Fix
- Yet another attempt to deal with asynchronous error handling in a sane way. Previously, errors in store handlers were being swallowed. This should fix that problem.
- New Feature
registerAll()
andregisterAllAsync()
@hugobessaa
- Bug Fix
- Fix connectToStores HoC to pass state instead of props.
- New Feature
- New higher-order component connectToStores, because why not. It works just like FluxComponent.
- Bugfix
- Switch back to using
cloneWithProps()
instead ofcloneElement()
to fix context passing with FluxComponent. See this issue for an explanation.
- Switch back to using
- Bugfix
- Add dummy handler to internal promise to prevent false warnings.
- New Feature
- Flux is passed as second parameter to custom render function of FluxComponent.
- New Store method
getStateAsObject()
is used inside default state getters forconnectToStores()
. This should be overridden alongsideStore.assignState()
. - New prop
stateGetter
for FluxComponent. (@tappleby) - Store no longer warns if
setState()
called outside dispatch handler. There are some valid reasons you may want to do this, primarily tests.
- Internal
- Updated dependencies.
- Bug Fix
- Add
Store.assign()
workaround for TypeScript, since it doesn't support extending static methods. (@ivw)
- Add
- New Feature
- Transactional state updates:
this.setState(state => ({ foo: state.foo + 1 }))
. - A new static method
Store.assignState()
can be overridden to customize the top-level state type. - Custom rendering in
FluxComponent
. Pass a function as therender
prop.
- Transactional state updates:
- Breaking Change
- FluxComponent and fluxMixin require React 0.13.
- Stores no longer use empty object as default state. Default state is null, like React.
- The array form of
connectToStore()
accepts a single state getter as the second parameter, which is passed an array of stores corresponding to the passed keys. - State getters are no longer auto-bound to the component. Props are passed as the second parameter.
- Directly-nested FluxComponents warn about mismatched parent and owner context. Not sure how to fix this yet, but it will work because of prop transfer, anyway. To avoid the warning, use
render
prop instead. connectToStores()
no longer checks if component is mounted before updating, sinceisMounted()
is deprecated in React 0.13. 99% of the time, this shouldn't be a problem, and it's easily worked around using therender
prop. Let me know if this is a serious issue for you.FluxComponent
updates incomponentWillReceiveProps()
instead ofcomponentDidUpdate()
, preventing extra render.
- Internal
- Remove undocumented method
Store#getState()
. - Favor
const
overlet
.
- Remove undocumented method
Big thanks to @tappleby, @hugobessaa, @gaearon, @emmenko, @ariabuckles, and everyone else who submitted a PR or an issue or contributed in any way.
- Bug Fix
- Small update to async actions so returned promise does not reject due to errors that occur in store handlers.
- New Features
Store#forceUpdate()
like React
- Bug Fix
- Fix requiring normal React instead of React with addons in FluxComponent.
- Bug Fix
- Fix bug when single item array is child of FluxComponent. #53
- Internal
- Updated tests to be compatible with React 0.13. Should be ready for final 0.13 release.
- Lint with eslint and babel-eslint.
- Polish
- Wrapped warnings in environment checks so they can be stripped in production, like React. #52
- Bug Fix
- Performing an action that hasn't been added to a Flux instance now warns instead throwing an error. #46
- New Features
- Flux emits an
error
event when errors occur as the result of an async action. This includes errors that occur inside the actions themselves and errors that occur in response to store state changes -- previously, these were being swallowed by the async action's promise, which made it difficult to debug. #50 - Action return values are now returned to the original caller, in addition to being dispatched. #46
- Flux emits an
- New Features
- Flux emits
dispatch
event on dispatch, with payload passed to listeners.
- Flux emits
- New Features
Flux#removeAllStoreListeners()
removes all listeners from all stores.
- Bug Fix
- Internal
- Updated Babel to 4.3.0
- New Feature
- Extra props set on FluxComponent will be injected into children. This lets you nest FluxComponents, so store getters on an inner FluxComponent can use props retrieved by an outer FluxComponent.
- FluxComponent no longer wraps a single child in a
span
. It only wraps if there are multiple children.
- [Documentation]
- Add sections clarifying how to access flux instance (e.g. to perform actions) using fluxMixin/FluxComponent
- New Feature
getStoreState()
in fluxMixin returns current combined state of connected stores.
- Bug Fix
- fluxMixin/FluxComponent will now updated when a prop change is detected, but not state. #29
- Documentation
- Add API docs for fluxMixin and FluxComponent. Included section explaining why a "key" prop should be passed to components that implement fluxMixin.
- Bug Fix
- Fix React peer dependency version so it works on 0.13
- New Feature
- New Feature
Store#registerAsync()
for doing optimistic updates in response to asynchronous actions- FluxComponent and fluxMixin for easy React integration
- Documentation
- React integration guide
- Minor updates
- Internal
- Updated dependencies
- Testing on iojs, for jsdom compatibility
Thanks to @vesparny, @martintietz, @SimonDegraeve for your input on new features.
- Bug Fix
Flux#deserialize()
was passing entire state string to stores, instead of the state string for each specific store. Thanks @martintietz for catching this! #15
- Internal
- Removed file
arrayIncludes.js
, which was no longer being used.
- Removed file
- New Feature
Store#register()
now accepts either action ids or actions themselves.
- Internal
- Action ids are stored directly on the action instead of in a separate collection.
- New Feature
- Added browser build using webpack, mostly just so we can keep an eye on bundle size.
- Documentation
- Updated README.md
- Added explanation of enforced unidirectional data flow to Actions.md
- Added recommended libraries section
- Internal
- Removed dependency on ES6 polyfills to reduce bundle size. Library assumes global Promise.
- Updated Makefile.
This release does introduce a few minor breaking changes... I contemplated bumping the version to 3.0, but the affected areas are such edge cases (undocumented and unsupported ones, at that) that I decided against it. The fact that the project is only, like, a week old was also a factor. In the future, as the API stablizes and matures, I'll try to be better about this.
The semver for this project is a little wacky, since the 1.0 version of this library existed for quite a while, but it was only ever used by me and was quite different in many ways. This is all a long-winded, extra cautious, apologetic way of me explaining why you should use (~) (or exact versions) for dependencies in your package.json
file instead of the default (^) — not just for this package, but for all packages.
(See "Why Semantic Versioning Isn't": https://gist.github.com/jashkenas/cbd2b088e20279ae2c8e)
- New Feature
- Serialization / Deserialization
Store#replaceState()
- Added alias
getConstants()
forgetActionIds()
- Better warning messages.
- Breaking Change
- Calling an action only return promises if the original action method returns a promise. Before, all actions returned promises, even if they were synchronous.
- Instantiating a base Store class will now throw an error. This is technically a "breaking" change, since you used to be able to do so, but it's certainly an edge case. More likely to break tests than actual code.
- Documentation
- API docs
- Internal
- Use spies to test warning messages.