dimanche 22 février 2015

How to handle relationships in a Flux application?

How can I handle relationships using Flux?


Lets say I have a Employee



{
id: 1
name: "Employee",
position: "Manager"
}


I have some log entries retrieved from the server api, that have a reference to employees



[
{
id: 1,
subject: "Subject",
employee: {
id: 1
name: "Employee",
position: "Manager"
}
},

{
id: 2,
subject: "Subject",
employee: {
id: 1
name: "Employee",
position: "Manager"
}
}
]


Currently I have 2 stores EmployeeStore and LogEntryStore.


The problem: If a employee changes his name a EMPLOYEE_UPDATED event would be triggered and the EmployeeStore will change the employee, but the LogEntryStore will still have the "outdated" employee.


Should every store that have a relationship also listen to EMPLOYEE_UPDATED? This seems inefficient to me.


How should I handle this?


Aucun commentaire:

Enregistrer un commentaire