react-state-rxjs
  • Introduction
  • Main differences
  • Performance first
  • GETTING STARTED
    • Instalation
    • Examples
  • Core concepts
    • Main idea
      • More complex flow visualization
    • Configuration
    • Store
      • Operators
      • Optimistic updates plugin
      • Form manager plugin
        • ShouldUpdateState hook
        • Custom form elements
      • Persist state plugin
        • Configuring custom storage
    • Actions
      • Immer
      • ImutableJs
      • Async
    • Components with Actions
    • @InjectStore decorator
    • @ComponentState decorator
    • ComponentState Hook
    • Dispatcher
    • Router / History
  • DIFFERENT SCENARIOS
    • Passing list item index via router
  • UNIT TESTING
    • Setup
    • Test store
    • Test actions
    • Test component with actions
    • Test with Enzyme
  • Debugging
    • Setup
    • Redux DevTools
    • Automated changes output
    • Manual state changes check
    • Additional debugging information
  • Production
    • Production mode
  • Other information
    • Best practices
    • CLI
      • Custom Configurations
    • Performance
    • Blog Posts
    • Contributing
Powered by GitBook
On this page

Was this helpful?

  1. Core concepts

Store

Store is observable object that holds all application state

PreviousConfigurationNextOperators

Last updated 6 years ago

Was this helpful?

Store can be accessed in one of 2 ways:

  • From

  • Or directly Store.store - but in this case you are responsible for subscription management and view update

public todos: [];

componentDidMount() {
        this.subscription = Store.store.select(['todos'])
        .subscribe(state => {
                this.todos = state; // OR this.todos = state.toJS()
                this.forceUpdate();
        })
}
    
componentWillUnmount() {
        this.subscription.unsubscribe();
}

render() {
        return (
                <div>{this.todos.getIn([0])}</div>
        )
}

TIP: try to avoid .toJS() calls because it is not the best practice and is might be costly performance vise.

Actions