- Fixes inheritance for actions #678
- Updates transmitter which fixes #665
- Upgrades babel and enables loose mode so IE10 can work again.
- Removes cannot push while pushing error from transmitter.
- Added jsnext:main so you can use rollup to bundle Alt. commit.
- Fix returning promises from an action. commit.
-
Removed this.dispatch from Actions commit.
Upgrade Guide
-
Use the included codemod to convert your actions.
-
You will need jscodeshift to run the codemod.
-
npm install jscodeshift -g
-
jscodeshift -t scripts/this-dispatch-to-return.js your_file.js
-
I recommend you use some source control like
git
this way you cangit diff
your changes and make sure everything is ok. -
You can manually upgrade by removing
this.dispatch
from your actions and instead return your payload directly. -
If you have an async action then you can return a function.
// from this class MyActions { someAction() { this.dispatch(13) } } // to this class MyActions { someAction() { return 13 } }
or
// from this class MyActions { asyncThings() { xhr('foo', () => { this.dispatch(42) }) } } // to this class MyActions { asyncThings() { return (dispatch) => { xhr('foo', () => { dispatch(42) }) } } }
-
-
Deleted all of
utils
,mixins
,components
, andaddons
from alt package.Upgrade Guide
- Use the utils found here.
- You can install these from npm.
- isMutableObject checks for frozen Objects before updating them commit.
- Fixes multiple actions from registering to the same handler commit.
- Fix FSA dispatching commit
- Stores created using an Object will now have a config. This gets rid of this issue. commit
- isPojo renamed to isMutableObject. commit
- This now checks if an object is frozen or not before attempting to delete keys from it.
- Can dispatch FSA actions directly through alt.dispatch. commit
- Makes alt FSA compliant. commit
- Removes the warning if nothing is dispatched. commit
- Fix regression for not setting state if reduce returns undefined. commit
- Allow dispatching action creators. commit
- Warn if nothing is dispatched. commit
- Pass store state to bootstrap lifecycle. commit
- setState now handles values. commit
- ImmutableUtil supports bootstrapping Records and more. commit
- Moved hot load delete of stores up to remove the warning shown in console. commit
-
Add
onMount
handler for AltContainer. commit -
Expose a reduce function for every store by default. commit
If you're using reducers then this allows you to not ever use waitFor since you can just call store.reduce(store.getState(), payload) in order to derive data.
-
Allow values for store state. commit
this.state can now be any valid JS value rather than always being an object.
-
Add some reducer utils. commit
These reducer utils can be used for easily working with reducer only stores
-
Return value from sources local method. commit
-
Delete stores on hot reload. commit
Working with react hot loader is now simpler.
-
Make fp tools faster by pulling directly from state. commit
-
Throw if listen does not get a function. commit
-
Change the connectToStores displayName. commit
-
Allow listening to same action with multiple methods. commit
- Returning a promise from action no longer makes the action dispatch by default. commit
-
Removed Symbol
Upgrade Guide
- Remove all references to Symbol, Symbol.keyFor, etc.
- Get access to the action's unique id via
myAction.id
-
Removed
getEventEmitter()
Upgrade Guide
- You can no longer access the internal event emitter to dispatch your own custom events. This is usually an anti-pattern.
- If you still need this behavior you can create your own event emitter in your store.
class TodoStore {
constructor() {
this.eventEmitter = new EventEmitter()
this.exportPublicMethods({
getEventEmitter: () => this.eventEmitter
});
}
}
-
Removed
_storeName
.Upgrade Guide
_storeName
was an internal property to the store where the store's name was kept.- You can now use
displayName
instead which is a public API.
-
Removed
stateKey
. commitUpgrade Guide
- A
stateKey
property was configurable on stores as well as app level. - This has now been removed.
- This key was mostly used so you can use the react-like API of
this.state
, now this is being supported first-class.
- A
// old behavior
class MyStore {
static config = { stateKey = 'state' }
constructor() {
this.state = {}
}
}
Now you can just use this.state
directly. If it exists it'll be picked up.
// old behavior
class MyStore {
constructor() {
this.state = {}
}
}
The old behavior of assigning state directly as instance properties will continue to be supported. However, this new behavior will be favored in the docs.
-
Render.toString/toStaticMarkup now return an object rather than a string of html.
Note: Render API is still in flux
Upgrade Guide
// old
Render.toString(App, props).then(markup => console.log(markup))
// new
Render.toString(App, props).then(obj => console.log(obj.html))
-
Render.toDOM no longer locks by default.
Upgrade Guide
- Render.toDOM used to "lock" meaning it wouldn't perform the fetches on the client when it rendered.
- Now this is configurable and off by default in case you want to use Render to render client side only.
// old
Render.toDOM(App, props, document.getElementById('react-root'))
// new
// the `true` is to not fetch client side.
Render.toDOM(App, props, document.getElementById('react-root'), true)
- A sweet new DispatcherDebugger react component which lets you debug your flux application on the browser. commit
- You may now return from actions directly in order to dispatch, no need to call
this.dispatch
. - connectToStores can now be used where you specify the methods at the callsite. commit
- statics addon lets you add your static methods to components that have been connected. commit
- TypeScript definitions!. commit
- Made the promise resolution to then(success, failure) so errors will be properly rejected. commit
-
componentDidConnect for connectToStores. Allows you to specify data fetching in there. commit
-
Hot reload of stores using webpack. commit
-
Reversed the then/catch in the promise resolution for data sources so the catch only handles data source failures. commit
-
Throw when passing
undefined
to store.unlisten. commit
-
preventDefault
to stop a store from emitting a change. commit -
observe()
a way for POJOs to observe for changes. commit -
otherwise()
listen to all dispatches that have not been bound in your stores. commit -
reduce()
listen to all dispatches in a store and return the new state. commit -
output()
transform the output that is emitted from the stores. commit -
Proper server rendering resolving all data at the component level before rendering. commit
-
Batched dispatches to avoid having componentWillMount cause a cannot dispatch while dispatching error when it loses context. commit
-
Alt.debug for registering your alt instance with chrome dev tools. commit
-
Function utils for transforming store state. commit
- interceptResponse method to data sources commit
- Revert breaking change back to merge state. 0.17.0 will include bootstrap, recycle, and flush replace state instead of merge state. commit
- local method in data source must return null or undefined to trigger remote commit
- Fixes bug with recycle for keys that weren't set at the beginning. commit
- Fixes isLoading for multiple async calls. commit
- @decorate(alt) to decorate your store and activate all @bind and @expose methods. commit
- getStores in conenctToStores decorator/wrapper function now receives props from a store. commit
- Solving the async debate. commit
- @bind and @expose decorators for binding actions and exporting public methods. commit
- Made the lifecycles eventemitters so you can bind multiple. commit
- Bug with react-native. Stop using the Object.assign polyfill since react-native overrides it with a non-spec compliant one. commit
- Updates es-symbol.
- Now passing more information through the dispatch about the action invoked. commit
This release is a pretty big one and it also marks Alt's first breaking changes.
Upgrade guide is included with each bullet point.
-
New method signatures for createStore, createActions, etc. commit
Upgrade Guide
- Previously all constructors for stores and actions received the alt instance as its first argument.
- You now have to pass this in yourself.
// old behavior
class MyStore {
constructor(alt) { }
}
// allows you to pass in your own arguments to the constructors
class MyStore {
constructor(alt, one, two, three) { }
}
alt.createStore(MyStore, null, alt, 1, 2, 3)
-
beforeEach/afterEach methods have been moved to lifecycle. commit
Upgrade Guide
- Previously the beforeEach and afterEach methods existed as a prototype method on the store.
- Now they are lifecycle methods.
// the new way
class Store {
constructor() {
this.on('beforeEach', () => {
});
}
}
-
withAltContext is now in decorator form. commit
Upgrade Guide
- Previously withAltContext took two arguments. The flux and the component.
- Now it takes a single argument, flux. It returns a function which takes another argument, the component.
As a decorator:
@withAltContext(alt) export default class App extends React.Component { render() { return <div>{this.context.flux}</div> } }
As a function:
export default withAltContext(alt)(App);
-
Lifecycle method serialize and deserialize have been renamed and moved. commit
Upgrade Guide
- Rename serialize to onSerialize.
- Rename deserialize to onDeserialize.
- Move those methods to your Store's configuration.
// new hotness class TodoStore { static config = { onSerialize() { }, onDeserialize() { } } }
-
atomicTransactions util has been renamed to just atomic. commit
Upgrade Guide
- Change all your import/require from
alt/util/atomicTransactions
toalt/util/atomic
- Change all your import/require from
-
Removed
mixins
from browser-with-addons. commit
Mixins are dead, all hail our new higher-order component overlords. Please use AltContainer instead: http://alt.js.org/docs/components/altContainer/
-
Method signature for beforeEach, afterEach, error lifecycle events have changed. commit
Upgrade Guide
- Previously the method signature looked like
fn(actionName, data, state)
. - Now it has been simplified to
fn(payload, state)
wherepayload
is an object. - The payload object contains keys
action
anddata
which contain the information from before.
- Previously the method signature looked like
class Store {
constructor() {
this.on('beforeEach', (payload, state) => {
console.log(payload.data);
});
}
}
- Time Traveling! commit
@timetravel
class TodoStore { }
TodoStore.undo(3);
TodoStore.redo(1);
- connectToStores function which also works with decorators. commit
@connectToStores
class TodoApp extends React.Component {
static getStores() {
return [TodoStoreStore]
}
static getPropsFromStores(props) {
return TodoStore.getState()
}
render() {
return (
<div>
{this.props.todos.map(todo => <Todo todo={todo} />}
</div>
)
}
}
- ImmutableJS support, in an addon as a decorator. commit
@immutable
class TodoStore {
constructor() {
this.state = Immutable.Map({})
}
}
- Use store references to take snapshots. commit
alt.takeSnapshot(TodoStore); // returns only TodoStore's snapshot
- Use store references to recycle. commit
alt.recycle(TodoStore); // recycles only TodoStore
- Simple decorators for creating stores and actions. commit
import { createStore } from 'alt/utils/decorators'
@createStore(alt)
export default class TodoStore {
constructor() {
}
}
- Apply transforms at the app level to modify each store before it is created. commit
alt.stateTransforms.push(Store => {
// make every store atomic
return atomic(alt)(Store)
})
- Add specific configuration to your stores, like how getState and setState behave. commit
class TodoStore {
static config = {
getState(state) {
// adds a new todo every time you getState
return states.todos.push({ 'Another todo!' });
}
}
}
- Create your actions inside the constructor by using instance properties. commit
class FooActions {
constructor() {
this.myAction = function (x) {
this.dispatch(x);
};
}
}
// inject lets you inject arbitrary props to your children
<AltContainer inject={{ foo: 7, bar: 'hello' }}>
<div />
</AltContainer>
// div gets prop foo=7 and bar='hello'
-
component
prop to AltContainer. commit -
alt has a
prepare
method which prepares a payload for bootstrapping. commit
// rather than rendering its children you can now pass in a component
<AltContainer component={MyComponent} />
// equivalent to
<AltContainer>
<MyComponent />
</AltContainer>
- Allow customizing where you assign your state as a key. commit
// if you yearn for a react-like API you can now has
const alt = new Alt({ stateKey: 'state' });
class Store {
constructor() {
this.state = {
stateGoesHere: 1,
yay: 2
};
this.nowItsPrivate = true;
}
}
// Customize the way getState and setState behave at the app level.
const alt = new Alt({
getState(state) {
// add fuzzlewuzzle to every state
state.fuzzlewuzzle = true;
return state;
},
setState(existingState, newState) {
// forget existingState, in with the new out with the old
return newState;
}
});
- Added
maxEvents
parameter to DispatcherRecorder. This allows you to specify how many events you wish to record. commit
- Performance improvement when creating a really large number of actions. commit
- finalStore is cached per alt instance so it only returns one. commit
- Override a store's name using
displayName
. commit - Fix context for nested components. commit
- Fix AltContainer and AltNativeContainer's rendering. commit
- setState now emits a change immediately if the dispatcher is not dispatching. commit
- Internals were refactored. commit
- Babel was upgraded to babel5. commit
- Action symbols are now prefixed with
alt/
. commit
- Adding unlisten lifecycle method. commit
- AltContainer now takes in store listeners for functions. commit
listen
now returns the unlisten function. commit
- setState has been batched, it emits a change event if there were changes. commit
- Util for having atomic transactions in stores. commit
- AltNativeContainer for react-native. commit
- Add shouldComponentUpdate to AltContainer. commit
- Centralized error handling inside stores. commit
- Creating single actions. commit
- You can now inject actions into your child React components using AltContainer. commit
- FinalStore now contains the payload as state. commit
- Chrome debugging exporter for devtool. commit
Added/### Fixed
- AltContainer can now receive new props and it'll change. commit
- A bug with
AltContainer
where it was using ES6 syntax. commit
AltContainer
which is a react container component that facilitates listening to stores and managing data. commitbeforeEach
andafterEach
hooks in stores for extending. commit- Allow custom dispatcher to be specified. commit
- Adds serialize/loadEvents to the DispatcherRecorder. You can now transfer events between different alt instances and machines. commit
- You can now get a list of a store's bound listeners with
boundListeners
. commit - Testing has been made even easier with access to the original store class with
StoreModel
. commit - takeSnapshot now allows you to take a snapshot of a single store. commit
rollback
,flush
, andrecycle
now emit change events. commit, commit- Adds AltManagerUtil which lets you manage multiple instances of alt. commit
- Fixes build on Windows. commit
- If a non-store is passed to bootstrap it no longer crashes. commit
- Added the
snapshot
method back in. commit
- Added react-native support. commit
- Create stores with a POJO. commit
- Add
serialize
/deserialize
lifecycle listener methods. commit - Add isomorphic rendering util. commit
emitChange
method lets you emit directly from within a store without having togetInstance
first. commit
Dev ### Dependencies
exportPublicMethods
can be used within a store to export public getter methods from the store. commit
- Future spec compliant change of making the derived store class call super before setting
this
. commit
- Browser builds for bower. commit
- The store name generator is now more robust. commit
- es-symbol has been updated to 1.1.1 commit
- createStore no longer throws when it encounters a store with the same name. Instead if generates a new name for you and warns you in the console. If a store name is not specified due to using anonymous functions then a warning is also logged. commit
- es-symbol has been updated to 1.1.0 for better IE8 compatibility. commit
- Added access to the internal EventEmitter used by the store. This can be access on the store instance by using
getEventEmitter()
and can be used for custom events. commit - Added a setState method for syntactic sugar which sets the state in the instance variables inside your store and then emits a change event. commit
- Added emitChange method. No more
this.getInstance().emitChange
, now you can justthis.emitChange()
from inside a store. commit - Added syntactic sugar for waitFor.
waitFor
now takes in a splat or array of stores or dispatch tokens. commit - The
alt
instance now gets passed to the store constructor as well as the actions constructor. commit - ActionListener is a util that allows you to listen in on specific actions. Now it's even more lightweight if you want to listen in on a specific action but don't want the weight of a store. This comes as a util meaning it doesn't increase the size of core alt. Use it if you need it. commit
- addStore now has the
saveStore
parameter as well. commit
- DispatcherRecorder is a util that allows you to record and replay a series of actions. commit
- FinalStore is a util Store that emits a change once all other stores have emitted. commit
- Added a
saveStore
parameter toalt.createStore
. This parameter controls whether we should save the store internally (for snapshots, bootstraps) or not. Default is true. commit
- All the mixins in the mixins folder don't make React complain about binding. commit
- Create context on
add
inSubscribe
mixin. commit
- Change lifecycle hook for
Listener
mixin toComponentWillMount
so that it functions are identical between server rendering and client rendering. commit
- Add
bindListeners
method to Store. This is the inverse ofbindActions
. commit - Create shorthand form of
createActions
,generateActions
. commit - Add/update several helpful mixins:
FluxyMixin
,ReactStateMagicMixin
, andSubscribe
. commit
- Add tests.
- Add
bower.json
to enable Alt with Bower. commit - Initial mixin pack addition. commit
ListenerMixin
updated tolistenTo
various stores. commit
- Upgrade to Babel 4.0 (formerly 6to5). commit
- Allow dispatching specific actions with any data. commit
- Remove dispatcher symbol from actions. commit
- Assure that store instances do not collide. commit
- Fix bug with defer where it is not variadic. commit
- Allow same action name on different Action Classes. commit
- Allow unlimited bootstraps. commit
- Replace lifecycle method API. commit
- Add lifecycle methods,
onBootstrapped
andonRolledBack
. commit - Distribute Alt with 6to5 runtime. commit
- Allow creating many instances of Stores. commit
- Add a class to safeguard call checks. commit
- Add
exportObj
argument tocreateActions
. commit
- Allow recycling of specific stores. commit
- Unlimited boostrapping on server. commit