Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Granularity of Modules #158

Open
tobiasbueschel opened this issue Mar 31, 2017 · 1 comment
Open

Granularity of Modules #158

tobiasbueschel opened this issue Mar 31, 2017 · 1 comment

Comments

@tobiasbueschel
Copy link

Thanks for the style guide 👍

When designing the component architecture of my app, the style guide recommends that every component should be bound to a module as shown below:


Approach 1

  • components.module
    • calendar.module
      • button.module
      • slider.module
import angular from 'angular';
import { ButtonModule } from './components/calendar/button.module';
import { SliderModule2 } from './components/calendar/slider.module';

export const CalendarModule = angular
  .module('calendar', [])
    ButtonModule,
    SliderModule
  ])
  .name;

However, when I have small components such as a button or slider it feels a bit heavy to tie them to their own modules especially if they do not have sub components. In fact, one could achieve the same effect as above using the following approach:


Approach 2

  • components.module
    • calendar.module
      • button
      • slider

import angular from 'angular';
import { Button } from './component/calendar/button';
import { Slider } from './component/calendar/slider';

export const CalendarModule = angular
  .module('calendar', [])
  .component('button', Button)
  .component('slider', Slider)
  .name;

  • Question 1: When should I use Approach 1 and when Approach 2 and why is one favoured over the other?
  • Questions 2: How granular should modules & components be?
@AkosLukacs
Copy link

AkosLukacs commented Apr 3, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants