Releases: minajevs/react-concise-state
1.2.0 Release
Store metadata release
New features
Store metadata. Now it is possible to provide some static data to store, which will be available both for actions and middleware. It can be used to provide API url/token to store, set some flags for dev/prod builds or handle some internal settings. Read more about it here.
Breaking API Changes
New middleware API. actionKey
parameter moved to new meta
object
Before:
const middleware: Middleware = (next, actionKey, args) => {
...
next(args)
}
Now:
const middleware: Middleware = (next, args, meta) => {
...
next(args)
}
1.1.0 Release
🎉Middleware release 🎉
Middleware proved to be very stable in my other pet projects, so it is good enough to be released.
New features
Middleware!
Now it is possible to inject custom middleware into stores. Read more about it here
Api changes
Store creator function now does not accept injected stores as a 3rd argument. Instead it takes special options
objects, which may or may not contain stores and middleware
Middleware pre-release 1.1.0-1
Middleware pre-release
I am planning to release middleware soon. This is a test version which includes all the planned features.
1.0.0 Release
🎉First big release 🎉
So, I finally feel comfortable enough to release the first version!
Api changes
Changed action creator signature. Should cover all the use cases now!
Commits
0.4.2 Patch
Minor bugfix. After previous patch action creators were broken if user explicitly set State type. Fixed it.
Also, a lot of house keeping.
0.4.1 Bugfix
Nothing major in this patch, except for small bugfix. Now it is possible to pass State type to creation function. Might be useful for type-first projects.
Commits:
- Fixed tsconfig not to build examples 082ce3d
- Merge branch 'master' of https://github.com/minajevs/react-concise-state c87b7ec
- Bugfix: predefault context to empty object it is important because as it is now it is not possible to provide state type dd6565a
- Create CODE_OF_CONDUCT.md 8e551b6
- Create LICENSE 3f12be2
- Update README.MD (remove todo examples) e7c7544
- Added redux todo example 4351095
- Still fixing links in readmes 2aa913a
- Trying out readme links 3720a08
- Added simple examples project 505ee6e
0.4.0 Release
Calling other stores from actions
Sometimes you would like to call other store action from an action. You can't use React.useContext
because of specific hook rules in React. Hook amount should never change during runtime and only way to supply that is to initialize all dependency contexts before bootstraping actions.
You can call actions in other stores by providing dependency contexts as a 3rd parameter to createStoreContext
. Those contexts will be mapped to corresponding stores internally and will be available in stores
object in {setState, action, stores}
argument of action creator.
Example:
const [todoContext, Provider] = createStoreContext({todos: []}, {
addTodo: ({state, setState}, todo) => {
setState({todos: [...state.todos, todo]})
},
})
const [mainContext, Provider] = createStoreContext({message: ''}, {
someAction: ({setState, stores}, name) => {
const { todos } = stores.todoContext // stores.todoContext is a "todo store" ({todos: [], addTodo: (todo) => void})
const newMessage = `Hello, ${name}, you have ${todos.length} todos!`
setState({message: newMessage})
},
}, {todoContext})
...
// Usage
const todoStore = React.useContext(todoContext)
const mainStore = React.useContext(mainContext)
todoStore.addTodo('buy milk')
todoStore.addTodo('learn typescript')
mainStore.someAction('Dmitrijs')
// mainStore.message is "Hello, Dmitrijs, you have 2 todos!"
Commits:
0.3.2 Bugfix
Bugfix
Fixed annoying TypeScript bug with lazy type inference in generics. Now all the types are resolved correctly.
0.3.0 Release
0.3.0 Release
Current state in action creators!
Now instead of only being able to modify state inside an action now you can also get current action :)
Before:
createContextState({foo: '123'}, {
bar: (setState) => { /* do something, probably call setState*/}
})
Now:
createContextState({foo: '123'}, {
bar: ({state, setState}) => { /* do something, get state values, probably call setState*/},
baz: ({setState}) => { /* can deconstruct only needed things */}
})
Unit-test, coverage, CI
Now the source code is covered with unit-tests & coverage analysis. Tests are run on every commit.
There are unit-tests not only for logic and behavior, but also for produced types.