仅保留1个州级的股票是否不好?
当我想对事件进行响应时,我需要克隆当前的状态实例,包括TODO列表。在某些情况下,例如,加载状态,根本不需要待办事项列表的存在,但是无论如何,克隆会发生。当待办事项清单很大时,这是否浪费了我需要担心的资源?
我在Flutter Bloc示例回购中看到了上面的一级方法,但是正在为每个状态创建一个单独的子类,例如tooveOverViewInitial,toDooverViewLoading,.etc更好的方法?
Take a todo app as an example. A typical State class might look like this:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论