Is there any recommended way to enhance action annotation? #3331
Answered
by
urugator
TotooriaHyperion
asked this question in
General
-
What I want is to simplify code like this: // current
class Example {
constructor() {
makeObservable(this, {
_doSomething: action.bound,
})
}
_doSomething() {}
doSomething = (...args) => {
let result;
// do something else(before) - a global configured behavior for debug or some other reason.
result = this._doSomething(...args);
// do something else(after)
return result;
}
// and many actions.
}
// expected
const higherOrderAnnotation = action.bound.intercept({
before: () => {},
after: () => {},
}); // or if there already has a simple pattern to solve this?
class Example2 {
constructor() {
makeObservable(this, {
_doSomething: higherOrderAnnotation,
})
}
doSomething() {}
} |
Beta Was this translation helpful? Give feedback.
Answered by
urugator
Mar 13, 2022
Replies: 1 comment 7 replies
-
No and there is no plan to provide this, at least until decorators are standardized. Possible alternatives: |
Beta Was this translation helpful? Give feedback.
7 replies
Answer selected by
kubk
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No and there is no plan to provide this, at least until decorators are standardized. Possible alternatives:
spy
this.action = intercept(this.action);