为我的 Rails 应用程序实现观察者模式
我目前正在使用 Rails 3.0.7 和 ruby 1.9.2 并制作一个 Rails 应用程序,其中包含从数据库加载的视频,同时由 FlowPlayer 渲染。以及基于视频的一组幻灯片。现在,我想将幻灯片与视频同步。对于时间安排,我要求用户输入每张幻灯片的时间安排。所以,我想知道是否可以通过将某种中心时间作为主题并将视频和幻灯片作为观察者来使用观察者模式?
虽然,在浏览了网上的许多教程后,这个概念似乎是正确的,但我无法继续或获得对其编码的想法。
任何帮助将不胜感激。
I am currently using rails 3.0.7 and ruby 1.9.2 and making a rails App which contains a video being loaded from a database while being rendered by FlowPlayer. and a set of slides based on the video. Now, I wanted to synchronize the slides with the video. For the timings, I am asking the user to enter the timings of each slide. So, I was wondering if i could use observer pattern for this by making a sort of central time as the subject and the video and slides as the observers?
While, the concept seems correct after going through a number of tutorials on the net, I am not able to proceed or ge ideas on coding it.
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,你有两种选择:
使用 ActiveRecord 的回调(before_save、after_save 等)或创建一个观察者
basically, you have two choices:
use ActiveRecord's callbacks (before_save, after_save, etc..) or create an observer