[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:
Currently you can only create stores in the root level.
E.g.
It would be nice to have a way of nesting stores, for better structure and readability
E.g.
The motivation would be to have stores more structured and readable. I'm currently using NGRX for every personal project and for work. I would like to switch over to Akita for personal projects and maybe even work, but i currently can't, because this should be an essential feature for state management.
Angular version: X.Y.Z
Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
For Tooling issues:
- Node version: XX
- Platform:
Others:
I'm not sure what is old. Can you provide the entity shape, please?
It's not supposed to be an entity, my bad. books and articles are stores.
And so are the two old.
What's is old? OldBooksStore?
For example yes, such as BooksStore has a "child" store called OldBooksStore and ArticlesStore has a "child" store called OldArticlesStore.
You can create sub stores:
export interface OldBooksState extends EntityState<Book> {}
export interface BooksState extends EntityState<Book> {}
@StoreConfig({ name: 'books' })
export class BooksStore extends EntityStore<BooksState> {
olds = new EntityStore<OldBooksState>({}, { name: 'old-books' });
constructor() {
super();
}
}
Same for the Query part.
There is no concept of a child because it doesn't give any value. You can also inject it:
export interface OldBooksState extends EntityState<Book> {}
export interface BooksState extends EntityState<Book> {}
@StoreConfig({ name: 'old-books' })
export class OldBooksStore extends EntityStore<OldBooksState> {
constructor() {
super();
}
}
export interface BooksState extends EntityState<Book> {}
@StoreConfig({ name: 'books' })
export class BooksStore extends EntityStore<BooksState> {
constructor(public olds: OldBooksStore) {
super();
}
}
Alright, i'll give that a try. I thought that was too simple coming from NGRX :(
Ok, if you need any help, join Akita's Gitter channel :)
Most helpful comment
You can create sub stores:
Same for the Query part.