Skip to content

Commit c006e3c

Browse files
committed
Improve documentation regarding deprecated Factory
1 parent 61977fc commit c006e3c

File tree

2 files changed

+53
-36
lines changed

2 files changed

+53
-36
lines changed

README.md

+42-33
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,30 @@ single [`run()`](#run) call that is controlled by the user.
1313

1414
* [Quickstart example](#quickstart-example)
1515
* [Usage](#usage)
16-
* [Loop](#loop)
17-
* [get()](#get)
18-
* [Factory](#factory)
19-
* [create()](#create)
20-
* [Loop implementations](#loop-implementations)
21-
* [StreamSelectLoop](#streamselectloop)
22-
* [ExtEventLoop](#exteventloop)
23-
* [ExtLibeventLoop](#extlibeventloop)
24-
* [ExtLibevLoop](#extlibevloop)
25-
* [ExtEvLoop](#extevloop)
26-
* [ExtUvLoop](#extuvloop)
27-
* [LoopInterface](#loopinterface)
28-
* [run()](#run)
29-
* [stop()](#stop)
30-
* [addTimer()](#addtimer)
31-
* [addPeriodicTimer()](#addperiodictimer)
32-
* [cancelTimer()](#canceltimer)
33-
* [futureTick()](#futuretick)
34-
* [addSignal()](#addsignal)
35-
* [removeSignal()](#removesignal)
36-
* [addReadStream()](#addreadstream)
37-
* [addWriteStream()](#addwritestream)
38-
* [removeReadStream()](#removereadstream)
39-
* [removeWriteStream()](#removewritestream)
16+
* [Loop](#loop)
17+
* [get()](#get)
18+
* [~~Factory~~](#factory)
19+
* [~~create()~~](#create)
20+
* [Loop implementations](#loop-implementations)
21+
* [StreamSelectLoop](#streamselectloop)
22+
* [ExtEventLoop](#exteventloop)
23+
* [ExtLibeventLoop](#extlibeventloop)
24+
* [ExtLibevLoop](#extlibevloop)
25+
* [ExtEvLoop](#extevloop)
26+
* [ExtUvLoop](#extuvloop)
27+
* [LoopInterface](#loopinterface)
28+
* [run()](#run)
29+
* [stop()](#stop)
30+
* [addTimer()](#addtimer)
31+
* [addPeriodicTimer()](#addperiodictimer)
32+
* [cancelTimer()](#canceltimer)
33+
* [futureTick()](#futuretick)
34+
* [addSignal()](#addsignal)
35+
* [removeSignal()](#removesignal)
36+
* [addReadStream()](#addreadstream)
37+
* [addWriteStream()](#addwritestream)
38+
* [removeReadStream()](#removereadstream)
39+
* [removeWriteStream()](#removewritestream)
4040
* [Install](#install)
4141
* [Tests](#tests)
4242
* [License](#license)
@@ -84,7 +84,7 @@ and run at the end of the program.
8484

8585
```php
8686
// [1]
87-
$loop = React\EventLoop\Factory::create();
87+
$loop = React\EventLoop\Loop::get(); // or deprecated React\EventLoop\Factory::create();
8888

8989
// [2]
9090
$loop->addPeriodicTimer(1, function () {
@@ -100,9 +100,10 @@ $stream = new React\Stream\ReadableResourceStream(
100100
$loop->run();
101101
```
102102

103-
1. The loop instance is created at the beginning of the program. A convenience
104-
factory [`React\EventLoop\Factory::create()`](#create) is provided by this library which
105-
picks the best available [loop implementation](#loop-implementations).
103+
1. The loop instance is created at the beginning of the program. This is
104+
implicitly done the first time you call the [`Loop` class](#loop) or
105+
explicitly when using the deprecated [`Factory::create() method`](#create)
106+
(or manually instantiating any of the [loop implementations](#loop-implementations)).
106107
2. The loop instance is used directly or passed to library and application code.
107108
In this example, a periodic timer is registered with the event loop which
108109
simply outputs `Tick` every second and a
@@ -134,18 +135,26 @@ Loop::get()->addTimer(0.01, function () {
134135
Loop::get()->run();
135136
```
136137

137-
### Factory
138+
### ~~Factory~~
139+
140+
> Deprecated since v1.2.0, see [`Loop` class](#loop) instead.
138141
139-
The `Factory` class exists as a convenient way to pick the best available
142+
The deprecated `Factory` class exists as a convenient way to pick the best available
140143
[event loop implementation](#loop-implementations).
141144

142-
#### create()
145+
#### ~~create()~~
143146

144-
The `create(): LoopInterface` method can be used to create a new event loop
145-
instance:
147+
> Deprecated since v1.2.0, see [`Loop::get()`](#get) instead.
148+
149+
The deprecated `create(): LoopInterface` method can be used to
150+
create a new event loop instance:
146151

147152
```php
153+
// deprecated
148154
$loop = React\EventLoop\Factory::create();
155+
156+
// new
157+
$loop = React\EventLoop\Loop::get();
149158
```
150159

151160
This method always returns an instance implementing [`LoopInterface`](#loopinterface),

src/Factory.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,31 @@
33
namespace React\EventLoop;
44

55
/**
6-
* The `Factory` class exists as a convenient way to pick the best available event loop implementation.
6+
* [Deprecated] The `Factory` class exists as a convenient way to pick the best available event loop implementation.
7+
*
8+
* @deprecated 1.2.0 See Loop instead.
9+
* @see Loop
710
*/
811
final class Factory
912
{
1013
/**
11-
* Creates a new event loop instance
14+
* [Deprecated] Creates a new event loop instance
1215
*
1316
* ```php
17+
* // deprecated
1418
* $loop = React\EventLoop\Factory::create();
19+
*
20+
* // new
21+
* $loop = React\EventLoop\Loop::get();
1522
* ```
1623
*
1724
* This method always returns an instance implementing `LoopInterface`,
1825
* the actual event loop implementation is an implementation detail.
1926
*
2027
* This method should usually only be called once at the beginning of the program.
2128
*
22-
* @deprecated Use Loop::get instead
29+
* @deprecated 1.2.0 See Loop::get() instead.
30+
* @see Loop::get()
2331
*
2432
* @return LoopInterface
2533
*/

0 commit comments

Comments
 (0)