Skip to content

Releases: minajevs/react-concise-state

1.2.0 Release

29 Jun 08:14
Compare
Choose a tag to compare

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)
}
  • Updated readme with meta data feature info d435606
  • Added store and middleware meta 85d57d4
  • Added middleware example 938d7c5
  • Update docs and examples to 1.1.0 750fd2a

v1.1.0...v1.2.0

1.1.0 Release

28 Jun 09:49
Compare
Choose a tag to compare

🎉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

v1.0.0...v1.1.0

Middleware pre-release 1.1.0-1

21 Jun 10:38
Compare
Choose a tag to compare
Pre-release

v1.1.0-0...v1.1.0-1

Middleware pre-release

19 Jun 11:54
Compare
Choose a tag to compare
Pre-release

I am planning to release middleware soon. This is a test version which includes all the planned features.

v1.0.0...v1.1.0-0

1.0.0 Release

13 Jun 12:44
Compare
Choose a tag to compare

🎉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

v0.4.2...v1.0.0

0.4.2 Patch

02 Apr 11:23
Compare
Choose a tag to compare

Minor bugfix. After previous patch action creators were broken if user explicitly set State type. Fixed it.
Also, a lot of house keeping.

  • Update docs 34b35fe
  • Added readme section about TypeScript Also a minor fix with predefaulted types c598714
  • Updated docs MD level 8274482
  • Update docs link 7cb6b30
  • Added docs d2f4eab
  • More examples and updated readme f68e54c
  • Update version in examples 5f531e8

v0.4.1...v0.4.2

0.4.1 Bugfix

29 Mar 13:51
Compare
Choose a tag to compare

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:

v0.4.0...v0.4.1

0.4.0 Release

20 Mar 13:16
Compare
Choose a tag to compare

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:

  • Added feature to call other stores afc27d1
  • Removed section about calling hooks inside actions fdce20c

v0.3.2...v0.4.0

0.3.2 Bugfix

19 Mar 09:40
Compare
Choose a tag to compare

Bugfix

Fixed annoying TypeScript bug with lazy type inference in generics. Now all the types are resolved correctly.

0.3.0 Release

16 Mar 13:36
Compare
Choose a tag to compare

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.

Commits

v0.2.0...v0.3.0