mirror of
https://github.com/zhigang1992/ReactiveCocoa.git
synced 2026-06-20 03:58:56 +08:00
Explain how signals start work upon instantiation
This commit is contained in:
@@ -133,7 +133,14 @@ handler finishes.
|
||||
|
||||
## The `Signal` contract
|
||||
|
||||
**TODO**
|
||||
|
||||
#### Signals start work when instantiated
|
||||
|
||||
When a `Signal` is created, it immediately executes the generator closure that
|
||||
was passed to the initializer. This means that instantiating a `Signal` may have
|
||||
side effects, or start work even before the initializer returns.
|
||||
|
||||
#### Observing a signal does not have side effects
|
||||
#### All observers of a signal see the same events at the same time
|
||||
#### Signals are retained until a terminating event occurs
|
||||
@@ -141,6 +148,8 @@ handler finishes.
|
||||
|
||||
## The `SignalProducer` contract
|
||||
|
||||
**TODO**
|
||||
|
||||
#### Signal producers start work on demand by creating signals
|
||||
#### Each produced signal may send different events at different times
|
||||
#### Signal operators can be lifted to apply to signal producers
|
||||
@@ -148,6 +157,8 @@ handler finishes.
|
||||
|
||||
## Best practices
|
||||
|
||||
**TODO**
|
||||
|
||||
#### Indent signal and producer chains consistently
|
||||
#### Process only as many values as needed
|
||||
|
||||
@@ -170,6 +181,8 @@ sooner, potentially saving a significant amount of work.
|
||||
|
||||
## Implementing new operators
|
||||
|
||||
**TODO**
|
||||
|
||||
#### Prefer writing operators that apply to both signals and producers
|
||||
#### Compose existing operators when possible
|
||||
#### Forward error and interruption events
|
||||
|
||||
Reference in New Issue
Block a user