Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to get react component instance from anywhere in the component tree. #1

Open
bhochhi opened this issue Jun 15, 2016 · 1 comment

Comments

@bhochhi
Copy link
Owner

bhochhi commented Jun 15, 2016

Currently, react-aop is unable to retrieve component instance. Tried with ref , ReactTestUtilities, and even reactElement but in vain. Because of this limitation, the current version limits you to be able add advice only on react component methods that doesn't reference to same component, this.

The work around currently implemented is by putting pointcut only in to the method that doesn't has reference to itself(this). In case you only have method with this, just need to create new method with no implementation and make it call from your originally intended method and make this new method your hook. For instance:

Original method in specification:

{

_onValidZipcode:function(target){
...original code...
this.otherFunInvoketion()
.
.
this._aopHook();
},
_aopHook:function(){}
}

And create the pointCut on _aopHook.

@k1r0s
Copy link

k1r0s commented May 30, 2017

Hi mate,

Googling about 'React cross-cutting concerns' I found this repo. Congrats, this is pretty nice. You have create an specific AOP solution for React. I don't have enough knowledge of React to indentify ccc far away from Logs or Ajax requests, but specific problems that AOP can solve in flux arquitectures (react related)

I'm looking for help to make examples of ccc problems solved by aop.

Please take a look over my repository. I wish colaborate with you to bring the benefits of AOP to React :)

https://github.com/k1r0s/kaop-ts/blob/master/docs/API.md#decorators

My advices can access everything of targeted classes or methods, even perform async tasks sequentially

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants