rintoj / statex

StateX is a state management library for modern web applications with unidirectional data flow and immutable uni-state (just like redux)
MIT License
68 stars 18 forks source link

[Question] Multiple States or deep nested States #2

Closed bergi9 closed 6 years ago

bergi9 commented 7 years ago

By design there is only one state.

If i use nested states i often get TS errors for possible undefined values. To workaround it i use if checks but that's repetive way.

I didn't found a way to have multiple states like:

@store()
export class FooStore {
  @action()
  foo(state:FooState, action: FooAction): FooState { ... }

  @action()
  bar(state:BarState, action: BarAction): BarState { ... }
}

Any suggestions?

rintoj commented 6 years ago

@bergi9, StateX is designed to work with single state. If you can share the snippet of code with your problem, I might be able to suggest how to fix.