条件渲染的上下文是否属于数据计算机?

发布于 2025-02-08 13:22:45 字数 328 浏览 3 评论 0原文

我终于将Xstate集成到我的工作项目中,因为我喜欢它,我很高兴能展示结构良好的状态可以做些什么来进行性能和推理,但是我正在为一些建模而苦苦挣扎。我有一个weathermachine,该根据lat/long获得当前温度,并连接到我的应用中的地图,因此当用户移动它时,天气会加载。我的工作都很好,但是如果用户放大过多,我不想显示天气,因为当您查看大面积时,这并不是那么有用。我的建模问题是隐藏天气是否属于天气机器。我的一部分认为,当我被要求时它应该只能天气天气。为hideweather添加某些上下文是最简单的,但是“正确吗?”是最简单的。对您所有人使用的方法的任何反馈都将不胜感激。

I'm finally integrating xstate into my work project because I love it and I'm excited to show off what well-structured states can do for performance and reasoning, but I'm struggling with a bit of modeling. I have a weatherMachine that gets the current temperature based on lat/long and is connected to a map in my app, so when the user moves it, the weather loads. I have that all working beautifully but if the user zooms out too much, I don't want to show weather, as it's not all that useful when you're viewing a large area. My modeling question is whether or not hiding the weather belongs in the weather machine. Part of me thinks it should just get weather when asked to but the point at which I dispatch the event to load weather (onMapRegionChange) is also the place I'd check the zoom level and show/hide the weather. It'd be simplest to add some context to the weather machine for hideWeather but is that "correct?" Any feedback on the approach you all would use would be greatly appreciated.

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

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

发布评论

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