Skip to content

Latest commit

 

History

History
964 lines (619 loc) · 32.7 KB

CHANGELOG.md

File metadata and controls

964 lines (619 loc) · 32.7 KB

Changelog

0.18.6

  • Fixes inheritance for actions #678

0.18.5

  • Updates transmitter which fixes #665

0.18.4

  • Upgrades babel and enables loose mode so IE10 can work again.

0.18.3

  • Removes cannot push while pushing error from transmitter.

0.18.2

  • Added jsnext:main so you can use rollup to bundle Alt. commit.
  • Fix returning promises from an action. commit.

0.18.0

Breaking Changes

  • 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 can git 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, and addons from alt package.

    Upgrade Guide

    • Use the utils found here.
    • You can install these from npm.

Changed

  • isMutableObject checks for frozen Objects before updating them commit.

0.17.9

Changed

  • Fixes multiple actions from registering to the same handler commit.

0.17.8

Changed

  • Fix FSA dispatching commit
  • Stores created using an Object will now have a config. This gets rid of this issue. commit

0.17.7

Changed

  • isPojo renamed to isMutableObject. commit
  • This now checks if an object is frozen or not before attempting to delete keys from it.

0.17.6

Added

  • Can dispatch FSA actions directly through alt.dispatch. commit

0.17.5

Added

  • Makes alt FSA compliant. commit

Changed

  • Removes the warning if nothing is dispatched. commit
  • Fix regression for not setting state if reduce returns undefined. commit

0.17.4

Added

  • 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

Changed

  • contextTypes are now copied onto connectToStores. commit
  • better typescript definitions. commit

0.17.3

Changed

  • Moved hot load delete of stores up to remove the warning shown in console. commit

0.17.2

Added

  • 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

Changed

  • 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

0.17.1

Changed

  • Returning a promise from action no longer makes the action dispatch by default. commit

0.17.0

Breaking Changes

  • 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. commit

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

Added

  • 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

Changed

  • Made the promise resolution to then(success, failure) so errors will be properly rejected. commit

0.16.10

Added

  • componentDidConnect for connectToStores. Allows you to specify data fetching in there. commit

  • Hot reload of stores using webpack. commit

Changed

  • 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

0.16.9

Added

  • 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

0.16.7

Added

  • interceptResponse method to data sources commit

Fixes

  • Revert breaking change back to merge state. 0.17.0 will include bootstrap, recycle, and flush replace state instead of merge state. commit

Changed

  • local method in data source must return null or undefined to trigger remote commit

0.16.6

Fixes

  • Fixes bug with recycle for keys that weren't set at the beginning. commit
  • Fixes isLoading for multiple async calls. commit

0.16.5

Added

  • @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

0.16.4

Added

  • @bind and @expose decorators for binding actions and exporting public methods. commit
  • Made the lifecycles eventemitters so you can bind multiple. commit

Fixes

  • Bug with react-native. Stop using the Object.assign polyfill since react-native overrides it with a non-spec compliant one. commit

0.16.3

Dependencies

  • Updates es-symbol.

0.16.2

Added

  • Now passing more information through the dispatch about the action invoked. commit

0.16.1

This release is a pretty big one and it also marks Alt's first breaking changes.

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 to alt/util/atomic
  • 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) where payload is an object.
    • The payload object contains keys action and data which contain the information from before.
class Store {
  constructor() {
    this.on('beforeEach', (payload, state) => {
      console.log(payload.data);
    });
  }
}

Added

@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);
    };
  }
}
  • All actions created are now available in alt.actions. commit

  • inject prop to AltContainer. commit

// 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

Fixes

  • 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

Changes

  • Internals were refactored. commit
  • Babel was upgraded to babel5. commit
  • Action symbols are now prefixed with alt/. commit

0.15.6

Added

  • Adding unlisten lifecycle method. commit
  • AltContainer now takes in store listeners for functions. commit
  • listen now returns the unlisten function. commit

0.15.5

Added

  • 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

0.15.4

Added

  • Chrome debugging exporter for devtool. commit

0.15.3

Added

  • Define your actions as POJO. commit
  • Use generateActions with alt instances. commit

0.15.2

Added/### Fixed

  • AltContainer can now receive new props and it'll change. commit

0.15.1

Fixed

  • A bug with AltContainer where it was using ES6 syntax. commit

0.15.0

Added

  • AltContainer which is a react container component that facilitates listening to stores and managing data. commit
  • beforeEach and afterEach 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, and recycle now emit change events. commit, commit
  • Adds AltManagerUtil which lets you manage multiple instances of alt. commit

Fixed

  • 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

0.14.5

Fixed

  • Added react-native support. commit

0.14.4

Added

  • 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 to getInstance first. commit

Dev ### Dependencies

  • Update babel to 4.7.13. commit
  • Update eslint to 0.17.1 and remove babel-eslint. commit.

0.14.3

Added

  • exportPublicMethods can be used within a store to export public getter methods from the store. commit

Fixed

  • Future spec compliant change of making the derived store class call super before setting this. commit

0.14.2

Added

  • Browser builds for bower. commit

Changed

  • The store name generator is now more robust. commit

0.14.1

Dependencies

  • es-symbol has been updated to 1.1.1 commit

0.14.0

Changed

  • 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

Dependencies

  • es-symbol has been updated to 1.1.0 for better IE8 compatibility. commit

0.13.11

Added

  • 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 just this.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

Fixed

  • addStore now has the saveStore parameter as well. commit

0.13.10

Added

  • 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 to alt.createStore. This parameter controls whether we should save the store internally (for snapshots, bootstraps) or not. Default is true. commit

Fixed

  • All the mixins in the mixins folder don't make React complain about binding. commit

0.13.8

Added

  • Create context on add in Subscribe mixin. commit

Fixed

  • Change lifecycle hook for Listener mixin to ComponentWillMount so that it functions are identical between server rendering and client rendering. commit

0.13.7

Added

  • Add bindListeners method to Store. This is the inverse of bindActions. commit
  • Create shorthand form of createActions, generateActions. commit
  • Add/update several helpful mixins: FluxyMixin, ReactStateMagicMixin, and Subscribe. commit

0.13.4

Added

  • Add tests.

0.13.5

Added

  • Add bower.json to enable Alt with Bower. commit
  • Initial mixin pack addition. commit
  • ListenerMixin updated to listenTo various stores. commit

0.13.3

Dependencies

  • Upgrade to Babel 4.0 (formerly 6to5). commit

0.13.2

Added

  • Allow dispatching specific actions with any data. commit
  • Remove dispatcher symbol from actions. commit

Fixed

  • Assure that store instances do not collide. commit
  • Fix bug with defer where it is not variadic. commit

0.13.1

Added

  • Allow same action name on different Action Classes. commit

0.13.0

Added

  • Allow unlimited bootstraps. commit

0.12.0

Added

  • Replace lifecycle method API. commit
  • Add lifecycle methods, onBootstrapped and onRolledBack. commit
  • Distribute Alt with 6to5 runtime. commit
  • Allow creating many instances of Stores. commit

0.11.0

Dependencies

0.10.2

Added

  • Add a class to safeguard call checks. commit

0.10.1

Added

  • Add exportObj argument to createActions. commit

0.10.0

Added

  • Allow recycling of specific stores. commit

0.9.0

Added

  • Unlimited boostrapping on server. commit

0.8.0

Added

  • Add recycle and flush methods. commit
  • Make stores available in alt.stores. commit