Giter VIP home page Giter VIP logo

Comments (6)

greg-murray-volusion avatar greg-murray-volusion commented on May 30, 2024 1

Does this mean we can now use kaop-ts with promises? Should this issue then be closed? Thanks

from kaop-ts.

k1r0s avatar k1r0s commented on May 30, 2024 1

keep in mind that you still rely on meta.commit to complete a task within each advice scope.

This change allows decorate methods that work with promises but inside advice operations you still have the same API

from kaop-ts.

k1r0s avatar k1r0s commented on May 30, 2024 1

🎉 This issue has been resolved in version 4.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from kaop-ts.

k1r0s avatar k1r0s commented on May 30, 2024

k1r0s/kaop@d3c6cb2

from kaop-ts.

k1r0s avatar k1r0s commented on May 30, 2024

Thanks for ur comment @greg-murray-volusion

I made that change on kaop lib (which is a hard kaop-ts dependency). I have to release a minor version simply pointing to last kaop version here.

You can try this feature now if you manually install latest kaop version on your project.

This change will make your methods wrapped with 'async' advices return a promise (or wrap existing one) in order to reflect that async process from outside of the method.

Before this change, if you had a method that returns a promise and you want to put advices on it, you couldn't properly return that promise if any of those advices contain an async task too.

I have to document that in deep, that's why this is still open :)

You can check these test in order to get more context
https://github.com/k1r0s/kaop/blob/master/test/promise-advice-method.spec.js

I can show you how this looks on es6 classes with real decorators:

this was somehow impossible with previous kaop version

const { beforeMethod, afterMethod } = require("kaop-ts");

const delay = beforeMethod(meta => setTimeout(meta.commit, 10))
const handleError = afterMethod(meta => meta.handle())

class Dummy {

  @delay
  do1() {
    return Promise.resolve(10)
  }

  do2() {
    return Promise.resolve(10)
  }

  @delay
  do3() {
    throw new Error("lmaooo")
  }

  @delay
  @handleError
  do4() {
    throw new Error("lmaooo")
  }
}

from kaop-ts.

greg-murray-volusion avatar greg-murray-volusion commented on May 30, 2024

Cool, thanks!

from kaop-ts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.