Releases: vigetlabs/microcosm
v9.4.1
v9.4.0
Noticeable changes
- Exposed lifecycle actions under
microcosm/lifecycle. See the
upgrading section for more notes.
Internal changes
getInitialState,serialize, anddeserializeare now triggered
by actions. We call them lifecycle actions. Their associated
counterparts arewillStart,willSerialize, and
willDeserialize. There is no obligation to use these lifecycle
actions, the store methods should work all the same.
Upgrading
This version adds lifecycle actions. This does not make any breaking
change to the Microcosm API, however it provides us better internal
consistency.
These lifecycle actions are still undergoing development (names may
change, etc, but we'll keep you posted). However if you would like to
give them a spin, consider the following code example:
import { willStart } from 'microcosm/lifecycle'
import { addPlanet } from 'actions/planets'
const Planets = {
reset() {
return []
},
add(records, item) {
return records.concat(item)
},
register() {
return {
[willStart] : Planets.reset,
[addPlanet] : Planets.add
}
}
}Version 9.3.0
Noticeable changes
- Store registration methods can return non-function values. When this
is the case, it will use this value as the new state.
Version 9.2.0
Noticeable changes
- Plugins will now validate that their
registerproperty is a
function. If this property is not present, it will skip this
validation and continue to the next plugin.
Internal changes
- Internalized
is-generatorpackage to reduce dependencies and cut
some dead code. - Refactored the install process to prevent needless extension and
simplify the installation queue.
Upgrading
All changes are purely internal polish. There should be no additional required action. The build is about 100 bytes smaller, but who's counting? :)
Version 9.1.0
Internal changes
- Updates to the way transactions are created and rolled forward to improve
efficiency and support dev tool development
Version 9.0
Noticeable changes
- Microcosm now uses transactions to process state. When an action is pushed,
an associated transaction will be created. Transactions are processed in the
order in whichapp.pushis called. - Added a mechanism for optimistic updates using generators in actions. (see the guide on Actions)
app.pushaccepts a callback as the third argument which will be invoked when an action is completely resolved (More in breaking changes)
Breaking Changes
- Removed Foliage. Microcosm no longer extends from Foliage and its API is no longer available.
- Instead of
app.getorapp.toObject()to retrieve state, useapp.state. - The signature for
app.pushis nowapp.push(action, [...arguments], callback). - The signature for
app.prepareis nowapp.prepare(action, [...arguments]).
Upgrading
Foliage
For those using the Foliage API, consider using Foliage within Stores themselves.
app.push
app.push should continue to work as expected when only one parameter is pushed to an action, however those pushing multiple parameters should make the following change:
// Before:
app.push(action, 'one', 'two',' 'three')
// After:
app.push(action, ['one' ,'two', 'three'])
Additionally, the third argument of app.push is now an error-first callback.
When an action resolves or fails, it will execute this callback:
app.push(action, params, function(error, body) {
if (error) {
handleError(error)
}
})Getting app state
All instances of app.get('key') should be replaced with app.state.key, sort of like
if it were a React Component
Version 8.3.0
Noticeable changes
- Microcosm will emit events synchronously. In the past, it would use requestAnimationFrame to batch together changes. However this can cause unexpected consequences when sequentially performing otherwise synchronous operations. For those who wish to preserve this behavior, consider using debounce to "choke" high frequency changes.
Version 8.2.0
Internal Changes
- Upgrade Foliage to
0.24.0. - Moved
Store.prototype.sendtoStore.send. This has always been
an internal API, however those using this method for testing will
need to update. This change is motivated by a desire to reduce as
much surface area from Store instances as possible. - We now use
babel-plugin-object-assignfor extension - Microcosm is compiled in normal babel mode (not loose)
Fixes
- Store responses to actions will always be called within the scope of the store.
- Addressed classical inheritance issue not caught from
loosebabel compilation
Upgrading
For those using Store.prototype.send, the following change is
necessary:
// Before
store.send(state, action, payload)
// After
Store.send(store, action, state, payload)Version 8.1.0
Noticeable changes
- Stores no longer return
thisfromregister()by default. This is a potentially breaking change, however should not pose a problem to projects using idiomatic Store registration. - Scope of store reducers when dispatching will always be the Store
Internal Changes
- Added plugin class to manage defaults
tagnow includes the name of the function intoString()- Unique ids for plugins and actions are internally generated with counters
Version 8.0.0
Noticeable changes
- Stores now contain the logic for how it should receive an action.
logic is contained undersend. - Stores now contain the logic to determine what method should resolve
an action sent to it. This is defined inregister Microcosm::deserializewill now only operate on the keys provided
by the seed object. This means that data passed intoreplace
will only blow way keys provided in the data object.- The signaling logic for dispatching actions will throw an error if
the action provided is not a function - Internalized tag, it will now lazy evaluate as actions are fired
- Upgraded Foliage, Microcosm now contains
subscribe,unsubscribe, andpublishaliases forlisten,ignore, andpublish
Breaking Changes
- Remove all uses of the
tagmodule.
Changes to Stores
Before this release, stores would listen to actions using the stringified value of their functions:
var MyStore = {
[Action.add](state, params){}
}This was terse, however required actions to be tagged with a special helper method. It also required any module that needed access to a Store's method to also know what actions it implemented.
To address these concerns, Stores now communicate with a Microcosm using the register method:
var MyStore = {
register() {
return {
[Action.add]: this.add
}
},
add(state, params){}
}Under the hood, Microcosm tags functions automatically.