Is it possible to delete a View? #1182
-
Hi! I'm struggling to delete a View and cannot find a function for it on the Collection. We are building an application that can show an individual resource in several different locations/components. And we run into issues when/if the resource is deleted. We then hold and try to render a deleted resource (which understandably throws exceptions). Our thinking for how to address this is to create a View to not hold a direct ref to Models that can be removed. This works great and we now hold Views even if it contains only 1 element. The problem now is that Views can only be added and never removed, so datx builds up a huge list of Views over time we cannot clean up. The work around is to "reuse" deleted views. They never get deleted from the collection, but we can mark them as "unused" in the service layer and give an existing View to new components. This feels a bit hacky :/ Is there a missing removeViewFromCollection somewhere not mentioned in the docs? BR / M |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @mikael-floden, The views can be used in two ways - one is as part of a collection and the second one is by itself. The second way should work for your use case because it's meant for use-cases where dynamic views are needed. |
Beta Was this translation helpful? Give feedback.
Hi @mikael-floden,
The views can be used in two ways - one is as part of a collection and the second one is by itself. The second way should work for your use case because it's meant for use-cases where dynamic views are needed.
So, instead of adding views to he collection, just create a new instance of the View.