Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to define the relationship in vuex's state

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

How to define the relationship in vuex's state

When you use vuex state, how to define relationship between state objects?

Avatar for Tetsuya Tatsumi

Tetsuya Tatsumi

March 09, 2018

More Decks by Tetsuya Tatsumi

Other Decks in Programming

Transcript

  1. %FpOFSFMBUJPOTIJQCZ SFGFSFODF TUBUF\ TIPQT<BFPO ZPLBEP>  EJTDPVOUT< \OBNFb͓٬༷ײँσʔ` TIPQBFPO^ 

    \OBNFb͋Γ͕ͱ͏σʔ` TIPQBFPO^  \OBNFbϋοϐʔσʔ` TIPQZPLBEP^ > ^
  2. %FpOFSFMBUJPOTIJQCZ*% TUBUF\ TIPQT<\JE OBNFbΠΦϯ`^  \JE OBNFbϤʔΧಊ`^>  EJTDPVOUT< \OBNFb͓٬༷ײँσʔ`

    TIPQ@JE^  \OBNFb͋Γ͕ͱ͏σʔ` TIPQ@JE^  \OBNFbϋοϐʔσʔ` TIPQ@JE^ > ^
  3. 3FGFSFODFPCKFDUJT SFQMBDFEUPWBMVF TUBUF\ TIPQT<\OBNFbBFPO`^ \OBNFbZPLBEP`^>  EJTDPVOUT< \OBNFb͓٬༷ײँσʔ` TIPQ\OBNFbBFPO`^^ 

    \OBNFb͋Γ͕ͱ͏σʔ` TIPQ\OBNFbBFPO`^^  \OBNFbϋοϐʔσʔ` TIPQ\OBNFbZPLBEP`^^ > ^
  4. 3FGFSFODFSFDPOTUSVDUJT OFFEFE var storage = JSON.parse localStorage.getItem bkey' var shops

    = new Map storage.shops.map i => <i.id i> for var discount of storage.discounts { discount.shop = shops.get discount.shop.id } this.replaceState Object.assign state storage