On Fri, Jun 04, 2010 at 05:06:02PM -0700, I. E. Smith-Heisters wrote: > > Building on the thread here: > http://groups.google.com/group/openwferu-users/browse_thread/thread/88d64384a3015aa7 > > ... our users need to interact with stored workitems, which begs a > question I've seen posted on this list before: how to force Ruote to > behave synchronously, so that users can see their changes to the > system immediately (in our case, they'd otherwise have to reload a web > page).
Hello Ian, in the context of a "web page", what about having the page refresh itself intermittently, à la Gmail ? Or if your users have an up-to-date browser, what about [ab]using websockets and let the server notify the web page of new workitems ? > I refactored John's example, and came up with the following: > > ----8<---- > class PatientParticipant < Ruote::StorageParticipant > class NestedWaitForError < StandardError; end > cattr_accessor :waiting > class << self > def wait_for signal=:next, &block > raise NestedWaitForError, "nesting wait_for is not currently > supported" if self.waiting > begin > self.waiting = [Thread.current, signal] > block.call > Thread.stop if waiting > Thread.current['__patience_result__'] > ensure > self.waiting = nil > end > end > > def continue workitem > return unless waiting > thread, waiting_for = *waiting > signals = [:next, workitem.participant_name] > if signals.include? waiting_for > thread['__patience_result__'] = workitem > thread.wakeup > end > end > end > def consume workitem > super workitem > self.class.continue workitem.dup > end > end > ---->8---- > > My controller might look like this: > > ----8<---- > FooController < ApplicationController > def update > PatientParticipant.wait_for :next do # "participant_x" works too > # reply to the engine with #params > end > end > end > ---->8---- > > The *only* place I'd use this is where we reply to the engine on > behalf of a user, since I vastly prefer to embrace Ruote's > asynchronous model. > > Hope that helps someone. Thanks for sharing your experiences. It's true that we're all a bit wary of "anticipating the flow", because it usually means that changing the flow will break the anticipations / expectations. I hope you're having good fun and that ruote helps you in your work. Cheers, -- John Mettraux - http://jmettraux.wordpress.com -- you received this message because you are subscribed to the "ruote users" group. to post : send email to [email protected] to unsubscribe : send email to [email protected] more options : http://groups.google.com/group/openwferu-users?hl=en
