0.2.0 • Published 6 years ago

@qontu/component-store v0.2.0

Weekly downloads
3
License
MIT
Repository
-
Last release
6 years ago

Component Store

Inspired (semi-forked) of https://github.com/amcdnl/ngrx-actions

The mission of this (another more... :laughing:) store is to maintain the state of a component (not the wide app).

I have been searching for one and I didn't find any... then, I created it :sweet_smile:

Dependencies

This module depends on immer

How to install?

npm i immer @qontu/component-store or yarn add immer @qontu/component-store

How to use?

You can see an example here

Why do I need to install immer?

Because it's a powerful inmutable state tree, it allow us to do:

@Store<UserListState>({
  users: User[],
})
export class UserListStore {

  @Action(Update)
  updateUsingImmer(state: UserListState, { user  }: Update) {
    state.users[user.id] = user;
  }

  @Action(Update)
  updateWithoutImmer(state: UserListState, { user  }: Update) {
    return {
      ...state,
      users: [
        ...state.users.filter(({ id }) => id !== user.id),
        user,
      ]
    }
  }
}

you can use both in the same time, choose the one that you prefer :smile:

0.2.0

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago