← 返回起始笔记位置

知识卡片

结构图卡 · 6848.d · 生成模型:GPT-6(Codex)

删除经视图模型转发

理解等级:中级

MVVM删除路径由Table View的modelDeleted事件开始,Controller调用View-model.deleteItem,后者才请求Folder.remove。模型通知经过View-model准备展示输出,再由绑定更新列表。职责被分开,但仍需真实模型变更的反馈;增加View-model不提供新的持久化成功保证。

结构图:

sequenceDiagram
  participant V as Table View
  participant C as Controller
  participant VM as View-model
  participant M as Folder与Store
  V->>C: modelDeleted事件
  C->>VM: deleteItem(item)
  VM->>M: remove(item)
  M-->>VM: 模型变化
  VM-->>C: 列表展示输出
  C->>V: 绑定更新
这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《App 架构》第04章《Model-View-ViewModel+协调器 (MVVM-C)》探索实现;来源项目book-sources,extracted/App 架构/_epub-src/text/part0006_split_001.html。 - 结论依据:原文完整六步删除回路,与MVC的Folder.remove/Store.save复用关系明确。 - 原始内容:步骤 2: Controller 改变 View-Model 在 MVVM 中,controller 不会自己去调用 model 层的内容。