2017-03-29 7 views
9

Ref:Eğik 4 + Redux (veya ngrx/mağaza) klasör ve dosya yapısı dosya yapısının Açısal resmi sitenin tarzı kurnazlık etmek

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

Ben Redux (veya ngrx/mağaza) uygulamaya istiyorsanız Yeni Angular 4 projeme, başvurumu bu şekilde yapılandırmak daha iyi olur mu?

 
    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 

Ya ngrx/mağazanın örneğini (https://github.com/ngrx/example-app), bu şekilde uygulamayı yapılandırmaya izleyin?

 
    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 
    │ │ │ │ │ └── ...... 
    │ │ │ ├── ...... 

Başka herhangi bir daha iyi yapı var mı?

+0

Ya kullanımı uygulaması/veya src benim akıllı bileşenleri

  • bileşenleri klasörü tutun tutun .. (src/app2, src/app3'e sahip değilseniz ve bu durumda, bu uygulamaları ayrı depolara ayırmadan src/app mantıklı değildir) –

  • +0

    Bunu ilk yoldan yaparım, ama sadece kişisel p Referans/görüşü. Bu yüzden yakın oy. – cartant

    +4

    Gelecekte, özellik modülleri kendi redüktörlerini ekleyebilecekler. Bu nedenle, her modülde ''/app/feature/store'' için bir dirim var ve 'feature.actions.ts',' feature.reducer.ts' ve 'feature.selectors.ts' içerir. – adharris

    cevap

    2

    proje kök ikinci yapıyı kullanıyoruz ama benim app büyüdükçe, bu bakımı zor başlamıştı, ve o zaman bu şekilde yapıyı tekrar elden

    ├── 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 
    │ │ │ │ │ └── ....... 
    │ │ │ ├── .... 
    

    , bu yapının artı noktasıdır, Gelecekte ngrx'i kaldırmaya veya düzenlemeye karar verirseniz, yapmanız gereken tek şey mağazaları klasörü kaldırmak veya düzenlemek.

    Not:

    • konteynerler klasör uygulaması kök klasör olarak/benim aptal bileşenler

    +1

    heros.store.ts model midir? –

    +0

    Model (varlık, arayüz) burada ne olacak? – Warapitiya

    İlgili konular