OVERMIND
v28
v28
  • Overmind
  • Introduction
  • Quickstart
  • How to learn
  • Videos
  • FAQ
  • Core
    • Devtools
    • Configuration
    • State
    • Actions
    • Effects
    • Operators
    • Server Side Rendering
    • Typescript
  • views
    • React
    • Angular
    • Vue
    • Svelte
  • Addons
    • GraphQL
    • Statechart
  • Guides
    • Using state machines
    • Using classes
    • Connecting components
    • Managing lists
    • State first routing
    • Testing
    • Connecting to React Native
  • API
    • action
    • addFlushListener
    • addMutationListener
    • createOvermind
    • createOvermindMock
    • createOvermindSSR
    • derived
    • effects
    • events
    • json
    • lazy
    • merge
    • namespaced
    • onInitializeOvermind
    • operators
    • reaction
    • rehydrate
    • statemachine
Powered by GitBook
On this page
  1. API

onInitializeOvermind

If you need to run logic as the application initializes you can use the onInitializeOvermind action. This action receives the application instance as the input value. You can do whatever you want here. Set initial state, run an action, configure a router etc.

export const onInitializeOvermind = async ({
  state,
  actions,
  effects
}, overmind) => {
  const initialData = await effects.api.getInitialData()
  state.initialData = initialData
}
import { state } from './state'
import * as actions from './actions'

export const config = {
  state,
  actions
}
PreviousnamespacedNextoperators

Last updated 3 years ago