Skip to content

Releases: jesseskinner/hover

Hoverboard.compose

04 Dec 02:14
Compare
Choose a tag to compare

Hoverboard now has a compose function!

For more details, check out #16.

Version 2.0.0 - October 25, 2015

26 Oct 03:20
Compare
Choose a tag to compare

This is the second major version for Hoverboard, and makes some major API changes and simplifications.

Hoverboard now only takes an object of actions, with the following changes:

  • Each action method is essentially a reducer with the signature: function action (state, arg1, .., argN) { return newState }
  • When you call the action, you call it with just the arguments, eg. store.action(arg1, .., argN);
  • If the action reducer returns an object, it will be shallow merged into the state if the state is also an object.
  • The state passed to the action or to subscribers will be a shallow copy of the state, if it is an object, to prevent mutations.
  • Action method names are unchanged, ie. Hoverboard no longer prepends "on" to actions.

There are some other things that are new:

  • You can no longer pass a function to Hoverboard, nor return one from the actions.
  • Anything async response needs to go through an action, there is no way to setState otherwise.
  • You can no longer use a getInitialState method. Instead, you'll need to create an action that sets the initial state and then trigger that action on the store before using the store.
  • There are no longer this.getState, this.setState or this.replaceState methods.
  • You no longer have any need to use this with Hoverboard at all, so your actions can be pure functions.
  • Hoverboard is now only 555 bytes minimized and gzipped!

Here's an updated example:

var ClickCounter = Hoverboard({
    click: function(state, text) {
        return {
            value: state.value + 1,
            log: state.log.concat(text)
        };
    },
    reset: function() {
        // go back to defaults
        return {
            value: 0,
            log: []
        };
    }
});

// initialize with defaults
ClickCounter.reset();

// listen to changes to the state
var unsubscribe = ClickCounter(function (clickState) {
    document.write(JSON.stringify(clickState) + "<br>");
});

ClickCounter.click('first');
ClickCounter.click('second');

// reset back to empty state
ClickCounter.reset();

unsubscribe();

ClickCounter.click("This won't show up");

Check out the README for updated documentation and examples.

Version 1.3.0 - January 18, 2015

19 Jan 04:38
Compare
Choose a tag to compare

Two big changes here that make things more flexible:

  • State can now be any value, not just objects. If objects are used, they will still be merged via setState, but you can now use anything as your state.
  • Hoverboard no longer uses serializing to copy state. In fact, Hoverboard no longer prevents mutation at all. It's up to you whether to use serialization, Object.assign, or some other immutability library to protect your state by writing a custom getState method. If you want to use the old way Hoverboard did mutation protection, add this getState method to your stores:
var Store = Hoverboard({
    getState: function(state){
        return JSON.parse(JSON.stringify(state));
    }
});

These are the last changes I have planned for a while. Hoverboard is now only 769 bytes minimized and gzipped!

Version 1.2.0 - January 16, 2015

16 Jan 17:45
Compare
Choose a tag to compare

EventEmitter is no longer a dependency. This means Hoverboard has zero dependencies, and is only 800 bytes minified and gzipped! See #1

Version 1.1.0 - January 15, 2015

15 Jan 23:40
Compare
Choose a tag to compare

This release eliminates the dependency on Facebook's Dispatcher. See issue #1.

Version 1.0.0

08 Jan 05:54
Compare
Choose a tag to compare

Finalized the API, and documentation is done. It's ready to be used in the wild.
Looking forward to any and all feedback.