-
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.
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)
- 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
- 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