@@ -4,20 +4,64 @@ txEffect
44.. image :: https://travis-ci.org/python-effect/txeffect.svg?branch=master
55 :target: https://travis-ci.org/python-effect/txeffect
66
7+ txEffect is a small library for integrating Twisted and Effect, mostly
8+ around Deferred<->Effect interoperation. Documentation is available at
9+ https://txeffect.readthedocs.org/
10+
711`Effect `_ is a library for helping you write purely functional code by
812isolating the effects (that is, IO or state manipulation) in your code.
913Documentation is available at https://effect.readthedocs.org/.
1014
1115.. _`Effect` : https://github.com/python-effect/effect
1216
13- txEffect is a small library for integrating Twisted and Effect, mostly
14- around Deferred<->Effect interoperation. Documentation is available at
15- https://txeffect.readthedocs.org/
1617
17- Example
18- =======
18+ Examples
19+ ========
20+
21+ Perform an Effect to get a Deferred with `txeffect.perform `_.
22+
23+ .. _`txeffect.perform` : http://txeffect.readthedocs.org/en/latest/api/txeffect.html#txeffect.perform
24+
25+ .. code :: python
26+
27+ from txeffect import perform
28+ d = perform(my_dispatcher, some_effect)
29+ d.addCallback(log.msg)
30+
31+ Implement a performer for an intent that returns a Deferred with
32+ `txeffect.deferred_performer `_.
33+
34+ .. _`txeffect.deferred_performer` : http://txeffect.readthedocs.org/en/latest/api/txeffect.html#txeffect.deferred_performer
35+
36+ .. code :: python
37+
38+ from twisted.internet.defer import succeed
39+ from txeffect import `deferred_performer` _
40+
41+ @deferred_performer
42+ def perform_foo (dispatcher , intent ):
43+ return succeed(' hello, world' )
44+
45+ Perform standard `Delay `_ and `parallel `_ effects using asynchronous
46+ implementations with `txeffect.make_twisted_dispatcher `_.
47+
48+ .. _`Delay` : http://effect.readthedocs.org/en/latest/api/effect.html#effect.Delay
49+ .. _`parallel` : http://effect.readthedocs.org/en/latest/api/effect.html#effect.parallel
50+ .. _`txeffect.make_twisted_dispatcher` : http://txeffect.readthedocs.org/en/latest/api/txeffect.html#txeffect.make_twisted_dispatcher
51+
52+ .. code :: python
53+ from twisted.internet import reactor
54+ from txeffect import `make_twisted_dispatcher` _
55+
56+ dispatcher = make_twisted_dispatcher(reactor)
57+ p_effs = parallel([Effect(Delay(5 ), Effect(Delay(3 ), Effect(Delay(1 ))))])
58+ perform(dispatcher, p_effs).addCallback(
59+ lambda : print (" 5 seconds have passed!" ))
60+
61+
62+ Working examples can be found at the `effect-examples `_ GitHub repo.
1963
20- TBD
64+ .. _ `effect-examples` : https://github.com/python-effect/effect-examples
2165
2266
2367Thanks
0 commit comments