仅保留1个州级的股票是否不好?

发布于 2025-02-10 03:19:56 字数 407 浏览 1 评论 0原文

以TODO应用为例。典型的州类可能看起来像这样:

当我想对事件进行响应时,我需要克隆当前的状态实例,包括TODO列表。在某些情况下,例如,加载状态,根本不需要待办事项列表的存在,但是无论如何,克隆会发生。当待办事项清单很大时,这是否浪费了我需要担心的资源?

我在Flutter Bloc示例回购中看到了上面的一级方法,但是正在为每个状态创建一个单独的子类,例如tooveOverViewInitial,toDooverViewLoading,.etc更好的方法?

Take a todo app as an example. A typical State class might look like this:
enter image description here

When I want to change the state a little, in response to an event, I will need to clone the current state instance, including the todo list. In some cases, for example a loading state, the presence of the todo list is not necessary at all, but the cloning happens anyway. When the todo list is large, will it be a waste of resource that I need to worry about?

I see the one-state-class method above in the flutter bloc example repo, but is creating a separate subclass for each state, like TodoOverviewInitial, TodoOverviewLoading, .etc the better way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文