Skip to content

Releases: vigetlabs/microcosm

v9.4.1

13 Jan 18:28

Choose a tag to compare

  • Fixed bug where lifecycle methods used as registered actions did not
    properly stringify.

v9.4.0

13 Jan 18:28

Choose a tag to compare

Noticeable changes

  • Exposed lifecycle actions under microcosm/lifecycle. See the
    upgrading section for more notes.

Internal changes

  • getInitialState, serialize, and deserialize are now triggered
    by actions. We call them lifecycle actions. Their associated
    counterparts are willStart, 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

03 Sep 22:10

Choose a tag to compare

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

01 Sep 12:40

Choose a tag to compare

Noticeable changes

  • Plugins will now validate that their register property is a
    function. If this property is not present, it will skip this
    validation and continue to the next plugin.

Internal changes

  • Internalized is-generator package 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

17 Jul 18:21

Choose a tag to compare

Internal changes

  • Updates to the way transactions are created and rolled forward to improve
    efficiency and support dev tool development

Version 9.0

07 Jul 20:24

Choose a tag to compare

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 which app.push is called.
  • Added a mechanism for optimistic updates using generators in actions. (see the guide on Actions)
  • app.push accepts 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.get or app.toObject() to retrieve state, use app.state.
  • The signature for app.push is now app.push(action, [...arguments], callback).
  • The signature for app.prepare is now app.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

26 Jun 16:22

Choose a tag to compare

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

26 Jun 16:21

Choose a tag to compare

Internal Changes

  • Upgrade Foliage to 0.24.0.
  • Moved Store.prototype.send to Store.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-assign for 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 loose babel 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

03 Jun 21:26

Choose a tag to compare

Noticeable changes

  • Stores no longer return this from register() 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
  • tag now includes the name of the function in toString()
  • Unique ids for plugins and actions are internally generated with counters

Version 8.0.0

20 May 11:01

Choose a tag to compare

Noticeable changes

  • Stores now contain the logic for how it should receive an action.
    logic is contained under send.
  • Stores now contain the logic to determine what method should resolve
    an action sent to it. This is defined in register
  • Microcosm::deserialize will now only operate on the keys provided
    by the seed object. This means that data passed into replace
    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, and publish aliases for listen, ignore, and publish

Breaking Changes

  • Remove all uses of the tag module.

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.