freeride-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [FR-devel] modification to slot.


From: Yohanes Santoso
Subject: Re: [FR-devel] modification to slot.
Date: 08 May 2002 17:30:07 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

Thanks for the quick reply. I was being lazy in calling
bus.manager/data.somemethod as bus.somemethod.

Another thing is: is there anyway we can put more information on
notification? For example, if the buffer changes, I'd like to send out
notification. This is easily accomplished by
scratch.notify(:changed). However, I'd like to do two things:

1. Show what the changes are, something like: scratch.notify(:changed,
   diff) where diff is the difference between the old and the new content.

2. Give a chance for the subscriber to cancel the action represented
by the notification.  For example, in scratch.notify(:going_to_change,
diff), if some plugin, say the disk manager, thinks that the changes
will exceed the available disk space (please just assume that this is
a credible action), the disk manager will vetoed the changes. 

This can either be implemented in scratch, or, make use of the
existing messaging capability of the databus.

#1 can be done without databus modification by calling some certain
 methods when the notification is received. But this seems like
 workaround. Thus, may be notify can be modified to accept another argument?

#2 is a bit difficult without modification to slot, but with a minor
 modif, it can be done:

      def notify(event, slot = self, detail = nil)
        if @subscribers.size > 0
          @subscribers.each_value do |subscriber|
            if subscriber.kind_of? Proc
              result = subscriber.call(event, slot, detail) 
            else
              result = subscriber.databus_notify(event, slot, detail)
            end
            return subscriber if result == false
          end
        end
        return @parent.notify(event, slot, detail) if @propogate_notifications 
and @databus.propogate_notifications and @parent
      end

So, am I going about the right way?

YS.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]