Permalink
Browse files

Documented blinker 1.1 changes

  • Loading branch information...
1 parent c5b1755 commit 05108673685c709c9929ab0e76451b74d51fb79b @mitsuhiko mitsuhiko committed Jul 20, 2010
Showing with 21 additions and 4 deletions.
  1. +21 −4 docs/signals.rst
View
25 docs/signals.rst
@@ -79,17 +79,22 @@ variable. Whenever a template is rendered, the template object as well as
context are appended to it.
Additionally there is a convenient helper method
-(:meth:`~blinker.base.Signal.temporarily_connected_to`). that allows you
-to temporarily subscribe a function to a signal with is a context manager
-on its own which simplifies the example above::
+(:meth:`~blinker.base.Signal.connected_to`). that allows you to
+temporarily subscribe a function to a signal with is a context manager on
+its own which simplifies the example above::
from flask import template_rendered
def captured_templates(app):
recorded = []
def record(template, context):
recorded.append((template, context))
- return template_rendered.temporarily_connected_to(record, app)
+ return template_rendered.connected_to(record, app)
+
+.. admonition:: Blinker API Changes
+
+ The :meth:`~blinker.base.Signal.connected_to` method arrived in Blinker
+ with version 1.1.
Creating Signals
----------------
@@ -141,6 +146,18 @@ function, you can pass ``current_app._get_current_object()`` as sender.
that :data:`~flask.current_app` is a proxy and not the real application
object.
+Decorator Based Signal Subscriptions
+------------------------------------
+
+With Blinker 1.1 you can also easily subscribe to signals by using the new
+:meth:`~blinker.base.NamedSignal.connect_via` decorator::
+
+ from flask import template_rendered
+
+ @template_rendered.connect_via(app)
+ def when_template_rendered(template, context):
+ print 'Template %s is rendered with %s' % (template.name, context)
+
Core Signals
------------

0 comments on commit 0510867

Please sign in to comment.