2017-03-29 26 views
9

कोणीय आधिकारिक वेबसाइट के फ़ाइल संरचना की शैली छल करने के लिए रेफरी:कोणीय 4 + Redux (या ngrx/दुकान) फ़ोल्डर और फ़ाइल संरचना

https://angular.io/docs/ts/latest/guide/style-guide.html#!#04-06

मैं Redux (या ngrx/दुकान) को लागू करना चाहते हैं मेरे नए कोणीय 4 प्रोजेक्ट के लिए, क्या इस तरह से मेरे आवेदन को ढूढ़ना बेहतर होगा?

 
    project root 

    ├── src/ 
    │ ├── app/ 
    │ │ ├──stores/ 
    │ │ │ ├── heros/ 
    │ │ │ │ ├── heros.actions.ts|reducer|effects|store.ts 
    │ │ │ │ 
    │ │ │ │── ..../ 
    │ │ │ │ ├── ..... 
    │ │ │ 
    │ │ ├── containers/ 
    │ │ │ ├── heros/ 
    │ │ │ │ ├── heros.component.ts|html|css|spec.ts 
    │ │ │ │ │ └── ...... 
    │ │ │ 
    │ │ │ 
    │ │ ├── components/ 
    │ │ │ ├── hero-list/ 
    │ │ │ │ │ ├── hero-list.component.ts|html|css|spec.ts 
    │ │ │ │ │ └── ....... 
    │ │ │ ├── .... 

I have been using second structure but as my app grows, it was getting difficult to maintain, and then I refactored the structure in this way, the plus point of this structure is, if in future you decide to remove or edit ngrx all you need to do is remove or edit the stores folder. 

Note: 

- containers folder hold my smart components 

- components folder hold my dumb components 

या ngrx/दुकान के उदाहरण (https://github.com/ngrx/example-app), इस तरह से आवेदन की संरचना करने का पालन करें?

 
    project root 
    ├── src/ 
    │ ├── app/ 
    │ │ ├── actions/ 
    │ │ │ ├── hero.js 
    │ │ │ ├── hero-list.js 
    │ │ │ └── ...... 
    │ │ ├── reducers/ 
    │ │ │ ├── hero.js 
    │ │ │ ├── hero-list.js 
    │ │ │ └── ...... 
    │ │ ├── components/ 
    │ │ │ ├── heros/ 
    │ │ │ │ ├── hero/ 
    │ │ │ │ │ ├── hero-list.component.ts|html|css|spec.ts 
    │ │ │ │ │ └── ...... 
    │ │ │ │ ├── hero-list/ 
    │ │ │ │ │ ├── hero-list.component.ts|html|css|spec.ts 
    │ │ │ │ │ └── ...... 
    │ │ │ ├── ...... 

क्या कोई अन्य बेहतर संरचना है?

+0

या तो उपयोग एप्लिकेशन/या src/एप्लिकेशन रूट फ़ोल्डर के रूप में .. । (src/app तब तक समझ में नहीं आता है जब तक आपको src/app2, src/app3 पसंद नहीं है, और उस स्थिति में, उन ऐप्स को अलग-अलग रिपोज़ में अलग कर दें) –

+0

मैं इसे पहला तरीका करूँगा, लेकिन यह सिर्फ व्यक्तिगत पी है संदर्भ/राय। इसलिए करीबी वोट। – cartant

+4

भविष्य में, फीचर मॉड्यूल अपने स्वयं के reducers जोड़ने में सक्षम हो जाएगा। इस कारण से, मेरे पास प्रत्येक स्टोर में स्टोर '/ एप/फीचर/स्टोर' के लिए एक डीआईआर है, और इसमें 'feature.actions.ts',' feature.reducer.ts', और 'feature.selectors.ts' है। – adharris

उत्तर

2

परियोजना जड़

├── src/ 
│ ├── app/ 
│ │ ├──stores/ 
│ │ │ ├── heros/ 
│ │ │ │ ├── heros.actions.ts|reducer|effects|store.ts 
│ │ │ │ 
│ │ │ │── ..../ 
│ │ │ │ ├── ..... 
│ │ │ 
│ │ ├── containers/ 
│ │ │ ├── heros/ 
│ │ │ │ ├── heros.component.ts|html|css|spec.ts 
│ │ │ │ │ └── ...... 
│ │ │ 
│ │ │ 
│ │ ├── components/ 
│ │ │ ├── hero-list/ 
│ │ │ │ │ ├── hero-list.component.ts|html|css|spec.ts 
│ │ │ │ │ └── ....... 
│ │ │ ├── .... 

मैं दूसरी संरचना का उपयोग किया गया है, लेकिन जैसा कि मेरे ऐप बढ़ता है, इसे बनाए रखने के लिए मुश्किल हो रही थी, और उसके बाद मैं इस तरह से संरचना पुनर्संशोधित, इस संरचना का प्लस पॉइंट है, यदि भविष्य में आप ngrx को हटाने या संपादित करने का निर्णय लेते हैं, तो आपको स्टोर फ़ोल्डर को हटाने या संपादित करने की आवश्यकता होती है।

नोट:

  • कंटेनर फ़ोल्डर अपने स्मार्ट घटकों

  • घटकों फ़ोल्डर पकड़ होल्ड माई गूंगा घटकों

+1

heros.store.ts मॉडल है? –

+0

मॉडल (इकाई, इंटरफ़ेस) यहां क्या होगा? – Warapitiya

संबंधित मुद्दे