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

proxy is revoked when proxy is assigned to itself even when the property is ignored #75

Closed
Baumgaer opened this issue Feb 15, 2021 · 3 comments

Comments

@Baumgaer
Copy link

Hi again,

when I have a model, let's call ist ActiveUser, which is wrapped into a proxy with on-change and with a property "editingModel" which is an ignored key, the Proxy of ActiveUser on the property "editingModel" will be revoked when ActiveUser is assigned to editingModel.

Example:

// Expected
Proxy(ActiveUser {
    editingModel: Proxy(ActiveUser{}), // This is an ignored key which should be able to hold the same proxy
    anotherProperty: ...
})

// Currently
Proxy(ActiveUser{
    editingModel: ActiveUser{}, // Same Object as the Proxy target but not a proxy anymore
    anotherProperty: ...
})

I understand why this behavior of revoking the proxy when it is assigned to itself exists, but is it necessarry to have this behavior on ignored keys or keys which are not wraped into a proxy?

Sure you want to avoid loops but I think on-change schould be able to deal with circular structures without removing proxies.
Currently this makes my bachelor thesis a little bit mor complicated. ;)

@DarrenPaulWright
Copy link
Collaborator

Is the ActiveUser assigned to editingModel a reference to the same ActiveUser that editingModel is part of? A working code sample would be helpful.

@DarrenPaulWright
Copy link
Collaborator

Or could you just assign the unproxied ActiveUser to editingModel?

@Baumgaer
Copy link
Author

Baumgaer commented Mar 31, 2021

Sorry I totally forgot this. I solved it now by just checking if the model in the editingModel property is the same instance as the "owner". When yes I select the model directly from the store and otherwise I choose the editingModel.

Assigning the unproxied model is not an option because I have to check for changes.

Btw. Maybe I forgot to mention that the model instance on the editingModel is exactly the same instance as the wrapping object. So ActiveUser is assigned to itself. That's why an recursion occurres and I know that you added so code to avoid that when calling the changeCallback

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

No branches or pull requests

2 participants