Adobe Flex 缓存阵列
我的程序用 Facebook 页面提要中的数据填充一个数组,但每次我从一个选项卡转到另一个选项卡时,它都想重新加载此数据,有什么方法可以缓存此数组,以便它不会重新加载信息,除非它发生更改?
My program fills an array with data from a facebook page feed but every time i go from one tab to another it wants to reload this data, is there any way i can cache this array so that it will not reload the information unless its changed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这正是您的视图不应包含服务逻辑的原因。相反,您的视图应该调度一个请求服务调用的事件,而您的控制器(您确实有一个,对吧?)应该捕获该事件并决定是否对其采取行动。
This is exactly why your Views should not contain Service logic. Instead, your View should dispatch an event asking for the service call and your Controller (you do have one, right?) should catch that event and decide whether to act on it or not.
你怎么知道数据没有改变而不重新加载呢?
也许您需要的是存储上次服务调用的时间戳,而不是测量再次执行服务调用之前的时间量。
也许有 5 分钟的超时,如果用户在上次服务调用后的 5 分钟内连续更改选项卡,则阵列将保留先前加载的数据。
5 分钟后,如果用户改回该选项卡,则可以触发服务调用、加载数据,然后更新时间戳以防止加载。
How do you know the data hasn't changed without reloading it?
Maybe what you need is to store the timestamp of the last service call, than measure the amount of time before executing the service call again.
Perhaps with a 5-minute timeout, if the user continuously changes tabs within 5-minutes from the last service call, the array persists previously loaded data.
After 5-minutes, if the user changes back to that tab the service call can fire, load data, than update the timestamp to prevent loading.