Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Latest commit

 

History

History
54 lines (42 loc) · 1.02 KB

10 Cutting Angular cross-cuts.md

File metadata and controls

54 lines (42 loc) · 1.02 KB

Cutting Angular cross-cuts

Links

SOLID

  • Single responsibility principle (SRP)
  • Open closed principle (OCP)
  • Liskov substitution principle (LSP)
  • Interface segregation principle (ISP)
  • Dependency injection principle (DIP)

Caching

Caching crosscut levels of abstractions. Caching is a cross-cutting concern

These must be separated: caching, logging, ..

Caching aspect example

èxport class CacheAspect {
    beforeUserFinderGetInvocation(meta, id) {
        this.queryCache(lsCache, meta.method, id);
    }

    afterUserFinderGetInvocation(meta,id){
        this.setCache(lsCache, meta.method, id);
    }

    // same for Http
}

Using an aspect

AspectJS library: aspect.js

@Wove()
export class Http {
    get(url: string){
        ...
    }
}

export class CacheAspect {
    @before(/.*/, /^get)
    before(m, param) { ... }

    @after(/.*/, /^get/)
    after(m, id) { ... }
}