Skip to content

Releases: vigetlabs/microcosm

Version 3.2.0

27 Mar 20:23
Compare
Choose a tag to compare
  • Changed default shouldUpdate algorithm

Version 3.1.0

27 Mar 14:00
Compare
Choose a tag to compare
  • Microcosm::getInitialState() now accepts an options argument. This argument is passed down from the constructor.

Version 3.0.0

27 Mar 12:20
Compare
Choose a tag to compare
  • Changed data update pattern to more closely match Om. This means that Microcosm::merge has been replaced with Microcosm::swap. Additionally, Microcosm::reset has been added to completely obliterate old state.
  • Microcosm::addStore now only accepts one store at a time. It was not being utilized, gives poorer error handling, and makes let less clear the order in which Stores will process data.
  • The internal class Heartbeat was replaced with pulse. Pulse is a function that can act as a factory or decorator. When given an argument, it extends an object with emitter functionality, otherwise it returns a new object that implements the same API. This eliminates the possibility that the private _callbacks member of Heartbeat was overridden. It also reduces the use of classical inheritance, which yields some minor file size benefits by polyfilling less of the class API.

Version 2.0.1

26 Mar 15:29
Compare
Choose a tag to compare
  • Fix issue where empty arguments would break deserialize

Version 2.0.0

26 Mar 14:54
Compare
Choose a tag to compare
  • Replace default Microcosm::send currying with partial application using Microcosm::prepare
  • Throw an error if a store is added that does not have a unique identifier
  • Microcosm::set has been replaced with Microcosm::merge, so far set has only been used internally to Microcosm and merge dries a couple of things up

More info on removing currying

Currying has been removed Microcosm::send. This was overly clever and somewhat malicious. If an action has default arguments, JavaScript has no way (to my knowledge) of communicating it. One (me) could get into a situation where it is unclear why an action has not fired properly (insufficient arguments when expecting fallback defaults).

In a language without static typing, this can be particularly hard to debug.

In most cases, partial application is sufficient. In light of this, actions can be "buffered up" up with Microcosm::prepare:

// Old
let curried = app.send(Action)

// New
let partial = app.prepare(Action)

Microcosm::prepare is basically just fn.bind() under the hood. Actions should not use context whatsoever, so this should be a reasonable caveat.

Version 1.4.0

25 Mar 15:14
Compare
Choose a tag to compare
  • Store.deserialize returns the result of getInitialState if no state is given
  • Added Microcosm.swap to perform diffing and emission on change
  • Microcosm.seed will now trigger a change event
  • Heartbeat.js now invokes callbacks with callback.call(this)

Version 1.3.0

25 Mar 12:24
Compare
Choose a tag to compare
  • Microcosms will set the result of getInitialState when adding a store
  • Microcosms will execute deserialize on stores when running seed
  • Adding a store will now fold its properties on top of a default set of options. See ./src/Store.js for details.

Version 1.2.1

24 Mar 19:49
Compare
Choose a tag to compare
  • Fix bug introduced with Tag by exposing ES6 module

Version 1.2.0

24 Mar 15:12
Compare
Choose a tag to compare
  • All stores can implement a serialize method which allows them to shape how app state is serialized to JSON.

Version 1.1.0

23 Mar 20:22
Compare
Choose a tag to compare
  • Better seeding. Added Microcosm::seed which accepts an object. For each known key, Microcosm will the associated store's getInitialState function and set the returned value.
  • Exposed Microcosm::getInitialState to configure the starting value of the instance. This is useful for those wishing to use the immutable npm package by Facebook.
  • Microcosm will not emit changes on dispatch unless the new state fails a shallow equality check. This can be configured with Microcosm::shouldUpdate
  • Microcosm::send is now curried.