Vue source code analysis (6)-Vuex

1. Store initialization

  1. If it is not used Vue.use(Vuex)for installation Vuex, install it. In the installation phase , the hook is injected mixinglobally, and the beforeCreatehook is triggered for Storeinjection when the component is initialized
  2. Recursively traverse the configuration items, initialize moduleand build the moduletree
  3. Recursively traverse modulethe tree, each mounted moduleand wherein the state, getter, mutation, actionencapsulated and implanted intostore
  4. Create built-in vminstance, map stateand getterto vminstance dataand computedattribute
  5. Build mapmapping function and export, provide convenienceAPI

2. Value

renderOr get data during operation.
If the getteracquisition is passed , the built-in vmcalculation attribute process is triggered vm, and finally datathe reactive logic in the trigger is triggered

3. Assignment

Subsequent operations modify the data.
If by action, the trigger Storeconfiguration actionfunction, by committriggering mutationthe assignment of the function data, the final trigger vmin dataresponse to a logical formula

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44844528/article/details/106724681