⚠️ This lesson is retired and might contain outdated information.

Use AOP in Vue Components with TypeScript and Kaop-ts

Share this video with your friends

Social Share Links

Send Tweet
Published 7 years ago
Updated 7 months ago

Aspect Oriented Programming, AOP, allows to reuse logic across an entire app in a very neat way, decoupling it from the business logic. Kaop-ts bring us decorators in order to apply AOP. This lesson will show you how you can move cache and exception handling out of your business logic using TypeScript and Kaop-ts

David
David
~ 7 years ago

Kaop-ts improve the way he declare advices, now you can just do this:

const getCached = meta => {
  console.log('before exectued')
  const cached = localStorage.getItem('App_handler')
  if (cached) {
    meta.scope.userName = cached
    meta.prevent()
  }
}

// *Or better in this case
const getCached = afterMethod(meta => {...})

// Inside component
@beforeMethod(getCached)
   // *Or just @getCached
@afterMethod(setCache)
handler() {

instead of extend AdvicePool

Ciro
Ciro
~ 7 years ago

Hi, since kaop-ts@3.x you cannot extend from AdvicePool

Ref -> https://github.com/k1r0s/kaop-ts#whats-new-on-30

Metadata -> https://github.com/k1r0s/kaop-ts/blob/master/docs/api.md#metadata

Markdown supported.
Become a member to join the discussionEnroll Today