Comments (6)
Does this mean we can now use kaop-ts
with promises? Should this issue then be closed? Thanks
from kaop-ts.
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.
🎉 This issue has been resolved in version 4.1.0 🎉
The release is available on:
Your semantic-release bot 📦🚀
from kaop-ts.
from kaop-ts.
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.
Cool, thanks!
from kaop-ts.
Related Issues (20)
- reexport inject and provider from kaop pkg
- allow access to `...advices` throught function prop
- advice order is wrong when on stacked joinpoints [breaking changes]
- [docs] Chinese | Russian translation
- An in-range update of ts-jest is breaking the build 🚨 HOT 3
- An in-range update of @types/node is breaking the build 🚨 HOT 4
- The automated release is failing 🚨
- after constructor advices no longer stack HOT 1
- Function calls are not supported in decorators - Angular 7 HOT 3
- Version 4.0.0 silently changes target to es6 HOT 2
- utility to clear all decorators HOT 1
- An in-range update of rollup is breaking the build 🚨 HOT 48
- Result of advise's first execution repeating itself in following executions when running all tests HOT 4
- applyAspect not fully reading proto chain HOT 1
- Prevents + Commit HOT 3
- declaration for module 'kaop' is needed HOT 6
- Advices on functions defined as properties HOT 2
- Async advices HOT 1
- How do I apply advices to all the methods in every class/component in angular? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kaop-ts.