ng-state
  • Introduction
  • Main differences
  • Getting Started
    • Instalation
    • Examples
  • Core concepts
    • Main idea
      • More complex flow visualization
    • Configuration
      • Immer Setup
      • ImmutableJs Setup
    • Store
      • Operators
      • Optimistic updates plugin
      • Optimistic updates plugin
      • Form manager plugin
        • onChange hook
        • shouldUpdateState hook
        • Custom form elements
      • Persist state plugin
        • Configuring custom storage
    • Actions
      • Immer
      • ImmutaleJs
      • Injectable Actions
    • Components with Actions
      • Signal Actions
      • State Actions
    • @InjectStore decorator
    • @WithStore decorator
    • @ComponentState decorator
    • Dispatcher
  • Different scenarios
    • Passing list item index via router
    • ngOnChanges hook
    • FormManager pitfalls
  • Unit testing
    • Setup
    • Test store
    • Test actions
    • Test component with actions
    • Test with Angular TestBed
  • Debugging
    • Setup
    • Redux DevTools
    • Automated changes output
    • Manual state changes check
    • Additional debugging information
  • Production
    • Production mode
    • Server Side Rendering (SSR)
  • Other information
    • Best practices
    • CLI
      • Custom Configurations
    • Performance
    • Blog Posts
    • Contributing
Powered by GitBook
On this page

Was this helpful?

  1. Core concepts
  2. Store
  3. Form manager plugin

shouldUpdateState hook

n some cases you might need to postpone state update to some time for example until field is valid. In this case you can do use shouldUpdateState method

const form = this.store.select(['my-form-state-path']).form
    .bind(myForm)
    .shouldUpdateState(this.shouldUpdateState);
shouldUpdateState = (params: ShoulUpdateStateParams) => {
    return true;
}

ShouldUpdateStateParams:

  • form: FormGroupLike form that has being synced

  • state: any - state before update

  • value: any - current value

This event will not be triggered if you are updating form state from the code manually

PreviousonChange hookNextCustom form elements

Last updated 5 years ago

Was this helpful?