coffeeandcloud / angular-clean-architecture Goto Github PK
View Code? Open in Web Editor NEWThis repository demonstrates a basic way how to implement the clean architecture pattern introduced by Uncle Bob to web apps like Angular.
This repository demonstrates a basic way how to implement the clean architecture pattern introduced by Uncle Bob to web apps like Angular.
Hi first of all thanks for sharing your approach.
I think we could reduce the custom providers in the app module such as :
{provide: ElephantRepository, useClass: ElephantMockRepository}
By using either config being passed in a forRoot
static method (that ensures typing for provided classes ) or ConcreteImlementationModules .
// app.module.ts
...
import { elephantMockRepositoryFactory } from './data/repository/elephant-mock-repository/elephant-mock.repository';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
DataModule,
CoreModule.forRoot(elephantMockRepositoryFactory),
PresentationModule
],
bootstrap: [AppComponent]
})
export class AppModule { }
// core.module.ts
CoreModule {
static forRoot(factory: () => ElephantRepository ) {
return {
ngModule: CoreModule ,
providers: {
provide: ElephantRepository, useFactory: factory
}
}
}
}
Or
// app.module.ts
...
import { elephantMockRepositoryFactory } from './data/repository/elephant-mock-repository/elephant-mock.repository';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
DataModule,
CoreModule,
PresentationModule,
MockModule
],
bootstrap: [AppComponent]
})
export class AppModule { }
// mock.module.ts
@NgModule({
...
providers: [
{provide: ElephantRepository, useClass: ElephantMockRepository}
]
...
})
MockModule { ... }
Even more we could move it to the environment files removing any reference from mocks:
// environment.ts
export const environment = {
...
modules: [
MockModule
]
...
}
// environment.prod.ts
export const environment = {
...
modules: [
ConcreteImplementationModule
]
...
}
// app.module.ts
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
DataModule,
CoreModule,
PresentationModule,
...environment.modules
],
bootstrap: [AppComponent]
})
export class AppModule { }
What about the domain validation rules? How to integrate Angular Form Validation with the domain model without break the DRY principle?
In which layer do I have to implement the shared component?
In which layer do I have to implement the redux pattern?
Olá.
Primeiramente, parabéns por este projeto que ajuda a clarear bem as orientações da Clean.
Entendo que Rxjs é um detalhe. Por outro lado useCase pertence de certa forma ao dominio da apliçao. Nesse sentido, como pertencendo a uma camada mais interna, useCase não poderia "conhecer" Rxjs que é de camada externa.
Pergunto: Na linha 1 em que temos useCase dependendo de Rxjs fere a clean architecture?
First of all thanks for the approach 🚀
In order to reduce the
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.