- slides: https://speakerdeck.com/mgechev/cutting-angulars-crosscuts
- aspect.js https://github.com/mgechev/aspect.js
- Single responsibility principle (SRP)
- Open closed principle (OCP)
- Liskov substitution principle (LSP)
- Interface segregation principle (ISP)
- Dependency injection principle (DIP)
Caching crosscut levels of abstractions. Caching is a cross-cutting concern
These must be separated: caching, logging, ..
èxport class CacheAspect {
beforeUserFinderGetInvocation(meta, id) {
this.queryCache(lsCache, meta.method, id);
}
afterUserFinderGetInvocation(meta,id){
this.setCache(lsCache, meta.method, id);
}
// same for Http
}
AspectJS library: aspect.js
@Wove()
export class Http {
get(url: string){
...
}
}
export class CacheAspect {
@before(/.*/, /^get)
before(m, param) { ... }
@after(/.*/, /^get/)
after(m, id) { ... }
}