redux-zero
Advanced tools
Comparing version 2.0.0 to 2.1.0
# Changelog | ||
### 2.1.0 | ||
- Now you can pass a function to `setState`. Example: | ||
```javascript | ||
store.setState((state) => { | ||
return { | ||
counter: state.counter + 1, | ||
changed: true, | ||
}; | ||
}); | ||
``` | ||
### 2.0.0 | ||
@@ -4,0 +17,0 @@ |
{ | ||
"name": "redux-zero", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/redux-zero.cjs.js", |
@@ -1,11 +0,10 @@ | ||
# redux-zero | ||
<h1 align="center"> | ||
<img src="https://s1.postimg.org/7p3dmmc3nz/logo_redux_zero.png" alt="redux zero logo" title="redux zero logo"> | ||
<br> | ||
</h1> | ||
<p align="center" style="font-size: 1.2rem;">A lightweight state container based on Redux</p> | ||
### A lightweight state container based on Redux | ||
> Read [the intro blog post](https://medium.com/@matheusml/introducing-redux-zero-bea42214c7ee) | ||
- Single store | ||
- No reducers | ||
- Less boilerplate | ||
- No PropTypes | ||
- Smaller and simpler than [redux](https://github.com/reactjs/redux) | ||
- Written in TypeScript | ||
<hr /> | ||
@@ -20,2 +19,11 @@ ![](http://img.badgesize.io/concretesolutions/redux-zero/master/dist/redux-zero.min.js?style=flat-square) | ||
- Single store | ||
- No reducers | ||
- Less boilerplate | ||
- No PropTypes | ||
- Smaller and simpler than [redux](https://github.com/reactjs/redux) | ||
- Written in TypeScript | ||
## Installation | ||
@@ -42,5 +50,3 @@ | ||
```js | ||
var createStore = require('redux-zero').createStore; | ||
var Provider = require('redux-zero').Provider; | ||
var connect = require('redux-zero').connect; | ||
const { createStore, Provider, connect } = require('redux-zero'); | ||
``` | ||
@@ -58,7 +64,7 @@ | ||
First create your store. This is where your application state will live: | ||
First, create your store. This is where your application state will live: | ||
```js | ||
/* store.js */ | ||
import { createStore } from 'redux-zero'; | ||
import { createStore } from "redux-zero"; | ||
@@ -71,3 +77,3 @@ const initialState = { count: 1 }; | ||
Then create your actions. This is where you change the state from your store: | ||
Then, create your actions. This is where you change the state from your store: | ||
@@ -91,3 +97,3 @@ ```js | ||
Now create your component. With **redux-zero** your component can focus 100% on the UI and just call the actions that will automatically update the state: | ||
Now create your component. With **Redux Zero** your component can focus 100% on the UI and just call the actions that will automatically update the state: | ||
@@ -138,7 +144,7 @@ ```js | ||
## Inspiration | ||
**redux-zero** was based on this [gist](https://gist.github.com/developit/55c48d294abab13a146eac236bae3219) by [@developit](https://github.com/developit) | ||
**Redux Zero** was based on this [gist](https://gist.github.com/developit/55c48d294abab13a146eac236bae3219) by [@developit](https://github.com/developit) | ||
## Roadmap | ||
- Improve integration with Preact | ||
- Remove the context API | ||
- Extract 'connect' so that Redux Zero can be use with multiple frameworks | ||
- Add more use case examples (including unit tests) | ||
@@ -145,0 +151,0 @@ ## Docs |
@@ -5,3 +5,6 @@ export default function createStore(state = {}) { | ||
setState(update) { | ||
state = { ...state, ...update } | ||
state = typeof update === "function" ? | ||
{ ...state, ...update(state) } : | ||
{ ...state, ...update } | ||
listeners.forEach(f => f(state)) | ||
@@ -8,0 +11,0 @@ }, |
Sorry, the diff of this file is not supported yet
151
47172
34
595