Two ViewModels
, one is a store of roles
containing skills
:
final class RolesStore: ObservableObject {
@Published var roles: [Role] = []
.....
A role model is:
struct Role: Codable, Identifiable {
let id: String
var name: String
var skills: [Skill]
}
The other ViewModel
is a store of skills
:
final class SkillStore: ObservableObject {
@Published var skills: [Skill] = []
.....
The following shows what i want to do, remove a skill from SkillStore
(handy), and also have the deleted skill automatically removed from any role
that happen to have the skill in the RoleStore
:
As you can see, removing the skill handy
doesn't remove it from the role Ansatt
.
I am not sure how to do that, so I prepared a Xcode Playground anyone can clone from Github: https://github.com/imyrvold/roleSkills
There must be a way of having SkillStore
having a dependency on the skills in SkillStore
or is there no other way than looping through all the roles and remove the skill from all the roles that have this skill?