让我们说我有事件监听器来更新用户状态。
之前的状态:
{
email: "old@email.com",
name: "John"
}
事件按顺序排列:
eventA = {
fields: ["email"],
timestamp: 1541531309
before: {
email: "old@email.com"
},
after: {
email: "new@email.com"
}
}
eventB = {
fields: ["email", "name"],
timestamp: 1541531310
before: {
email: "old@email.com",
name: "John"
},
after: {
email: "new@email.com",
name: "Bill"
}
}
eventC = { // same as A
fields: ["email"],
timestamp: 1541531309
before: {
email: "old@email.com"
},
after: {
email: "new@email.com"
}
}
之后的期望状态:
{
email: "new@email.com",
name: "Bill"
}
如何正确过滤没有的事件:
一些数学/哈希/校验和魔术吗?
PS 。可以向事件本身添加更多信息。
谢谢。