Metadata-Version: 1.1
Name: GreenRocket
Version: 0.21
Summary: A simple and compact implementation of Observer design pattern
Home-page: https://bitbucket.org/kr41/greenrocket
Author: Dmitry Vakhrushev
Author-email: self@kr41.net
License: BSD
Download-URL: https://bitbucket.org/kr41/greenrocket/downloads
Description: Green Rocket
        ============
        
        Green Rocket is a simple and compact implementation of Observer
        (or Publish/Subscribe) design pattern via signals.
        
        Create specific signal using base one::
        
            >>> from greenrocket import Signal
            >>> class MySignal(Signal):
            ...     pass
            ...
        
        Subscribe handler::
        
            >>> @MySignal.subscribe
            ... def handler(signal):
            ...     print('handler: ' + repr(signal))
            ...
        
        Fire signal::
        
            >>> MySignal().fire()
            handler: MySignal()
        
        Note, that signal propagates over inheritance, i.e. all subscribers of base
        signal will be called when child one is fired::
        
            >>> @Signal.subscribe
            ... def base_hadler(signal):
            ...     print('base_handler: ' + repr(signal))
            ...
            >>> MySignal().fire()
            handler: MySignal()
            base_handler: MySignal()
        
        Unsubscribe handler::
        
            >>> MySignal.unsubscribe(handler)
            >>> MySignal().fire()
            base_handler: MySignal()
        
        The handler is subscribed using weak reference.  So if you create and subscribe
        a handler in local scope (for example inside a generator), it will unsubscribed
        automatically.
        
        ::
        
            >>> def gen():
            ...     @MySignal.subscribe
            ...     def local_handler(signal):
            ...         print('local_handler: ' + repr(signal))
            ...     yield 1
            ...
            >>> for value in gen():
            ...     MySignal(value=value).fire()
            ...
            local_handler: MySignal(value=1)
            base_handler: MySignal(value=1)
            >>> import gc                    # PyPy fails the following test without
            >>> _ = gc.collect()             # an explicit call of garbage collector.
            >>> MySignal(value=2).fire()
            base_handler: MySignal(value=2)
        
        As you can see above, signal constructor accepts keyword arguments.  These
        arguments are available as signal attributes::
        
            >>> s = MySignal(a=1, b=2)
            >>> s.a
            1
            >>> s.b
            2
        
        Signal suppresses any exception which is raised on handler call.  It uses
        logger named ``greenrocket`` from standard ``logging`` module to log errors and
        debug information.
        
        
        CHANGES
        =======
        
        0.21
        ----
        
        *   Removed distribute dependency
        *   Improved tests
        
        0.20
        ----
        
        *   Changed handler subscription mechanism from subscription by reference to
            subscription by weak reference
        
        0.11
        ----
        
        *   Fixed logger loose on program termination
        
        0.1
        ---
        
        *   Initial release
        
Keywords: signal observer publisher subscriber
Platform: UNKNOWN
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
