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

Problem with EntityEditor when it is not attached to a form #12

Open
arthef opened this issue May 26, 2020 · 2 comments
Open

Problem with EntityEditor when it is not attached to a form #12

arthef opened this issue May 26, 2020 · 2 comments
Assignees

Comments

@arthef
Copy link

arthef commented May 26, 2020

Ok, I do not know if this is related to EntityEditor or ListNode or NodeList. The thing is that I have AbstractEntityView implementation using EntityEditor and ListNode to render EntityList elements. Very similar thing to the ChatRoomView from RadChatRoom.
Now, I have several Views like this created. Think of it as several ChatRoomViews created. Each view corresponds to a different EntityList. Like you would have each ChatRoomView created for different person you talk with. Only one View is displayed on the screen though and a user can switch between these views to display a different one.

For performance reasons and to reduce resources usage, I do not want to create a View every time a user switched to this view. Once the View is created I keep it in a Map and when a user wants to see this View I just insert it into the form's Container. Everything works great, except adding Entity to EntityList when the View is not visible, that is when the View is not in the form's Container and it is stored in the Map.
When the View is visible on the screen, adding Entity shows it on the list. When it is not on the screen and stored in the Map then Entity is added to the EntityList but after I show the View on the form, this added Entity is not visible.

I guess, I should somehow refresh either EntityEditor or ListNode to render entities added when the View was in background. I cannot, however, find a suitable API.
Do you have any suggestions on how this could be accomplished?

@shannah
Copy link
Owner

shannah commented May 27, 2020

EntityViews are set to bind to their view models on init, and to unbind on deinit. This is to avoid memory leaks. If their view model is changed while they are not on a form, the won't be receiving change events from the view models.

Anyways, that is likely the problem that you're facing. I'll need to think a little bit about a solution for this problem. I can think of several off the cuff, but I'm sure that some thought will reveal which are most elegant.

@shannah shannah self-assigned this May 27, 2020
@arthef
Copy link
Author

arthef commented May 27, 2020

Thank you for looking into it. For now, I just destroy the view if it is in background and the attached EntityList is modified. This way the view is recreated when a user wants to show it on the screen and all the elements are displayed correctly.

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