Store

  • holds the app's state
  • dispatched actions
  • calls reducers
  • receives/stores new states

Store 메서드

const immaStore = Redux.createStore(<reducer>)

// returns the current state that's in the store
immaStore.getState()

// takes an action object
// and passes it to the reducer functions
immaStore.dispatch(<action object>)

// takes a listener function that will be called whenever the state changes
immaStore.subscribe(<listener function>)

getState()

앱의 현재 상태 트리를 반환한다.

dispatch(action)

액션을 보낸다. 이것이 상태변화를 일으키기위한 유일한 방법

subscribe(listener)

변경사항에 대한 리스너를 추가한다. 리스너는 액션이 보내져서 상태트리의 일부가 변경될 수 있을때마다 호출된다. 콜백안에서 현재 상태트리를 읽으려면 getState()를 호출하면된다.

results matching ""

    No results matching ""