# Composability

Sub-generators may execute other generators or sub-generators. It could be a better choice to divide jobs into multiple sub-generators. This will ease maintenance and increase reusability.

For example, you may generate models for your favorite ORM and documentation in Markdown. If you create two sub-generators such as orm and report, and an app sub-generator executing both, end-users may choose to execute one of them or all of them. Also, you can reuse them as necessary.

# this.composeWith()

The composeWith() method allows a generator to execute another generator.

export default class App extends PgGenerator {
  protected async init(): Promise<any> {
    return Promise.all([this.composeWith(require.resolve("../orm")), this.composeWith(require.resolve("../report"))]);
  }
}