Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
React (takeoffconf)
Search
Igor Wiedler
January 17, 2013
Programming
850
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
React (takeoffconf)
Igor Wiedler
January 17, 2013
More Decks by Igor Wiedler
See All by Igor Wiedler
Redis Bedtime Stories
igorw
1
390
Wide Event Analytics (LISA19)
igorw
4
960
a day in the life of a request
igorw
0
180
production: an owner's manual
igorw
0
210
The Power of 2
igorw
0
360
LISP 1.5 Programmer's Manual: A Dramatic Reading
igorw
0
500
The Moral Character of Software
igorw
1
340
interdisciplinary computing (domcode)
igorw
0
330
miniKanren (clojure berlin)
igorw
1
350
Other Decks in Programming
See All in Programming
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
460
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.7k
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
270
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
360
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
170
Event is what happens
moro
2
1.3k
Railsバージョンを4倍にした話
optim
0
550
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
Vue Fes Japan の “作る側”に関わってみて
naokihaba
1
180
Zero-Tap Sign-In対応、結局何をすればいいの?
mitohato14
0
450
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
1.1k
Kotlinの15年とServer-Side Kotlin
n_takehata
1
160
Featured
See All Featured
Designing for humans not robots
tammielis
254
26k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
580
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
570
The Pragmatic Product Professional
lauravandoore
37
7.5k
GitHub's CSS Performance
jonrohan
1033
470k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
GraphQLとの向き合い方2022年版
quramy
50
15k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
How to train your dragon (web standard)
notwaldorf
96
6.9k
Unsuck your backbone
ammeep
672
58k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.8k
Transcript
None
@igorwesome
None
None
None
var http = require('http'); var server = new http.Server(); server.on('request',
function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }); server.listen(1337, '127.0.0.1');
None
$server = stream_socket_server('tcp://127.0.0.1:1337'); while ($conn = stream_socket_accept($server, -1)) { fwrite($conn,
"HTTP/1.1 200 OK\r\n"); fwrite($conn, "Content-Length: 3\r\n\r\n"); fwrite($conn, "Hi\n"); fclose($conn); }
$s=stream_socket_server('tcp://[::1]:81'); while($c=stream_socket_accept($s,-1)) fwrite($c,"HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nHi");
stream_select
$readable = $read ?: null; $writable = $write ?: null;
$except = null; if (stream_select($readable, $writable, $except, 1)) { if ($readable) { foreach ($readable as $stream) { ... } } if ($writable) { foreach ($writable as $stream) { ... } } }
None
Event-driven, non-blocking I/O with PHP.
$loop = React\EventLoop\Factory::create(); $socket = new React\Socket\Server($loop); $http = new
React\Http\Server($socket, $loop); $http->on('request', function ($req, $rep) { $rep->writeHead(); $rep->end("Hello World!\n"); }); $socket->listen(8080); $loop->run();
Demo
EventLoop Stream Socket Http
Http HttpClient DNS
HttpClient Http DNS Stomp Whois
HttpClient Http DNS Stomp Whois WebSocket DNode SOCKS IRC
None
$foo->get(function ($bar) { $bar->get(function ($baz) { $baz->get(function ($bazinga) { $bazinga->get(function
() { throw new FuckItException(); }); }); }); });
async API (escaping callback hell)
React/Async
use React\Async\Util as Async; Async::waterfall([ function ($callback) use ($foo) {
$foo->get($callback); }, function ($bar, $callback) { $bar->get($callback); }, function ($baz, $callback) { $baz->get($callback); }, function ($bazinga, $callback) { $bazinga->get($callback); }, function ($callback) { throw new FuckItException(); } ]);
React/Promise
$dns ->resolve('igor.io') ->then(function ($ip) { echo "Host: $ip\n"; });
$promise ->then('doStuff') ->then('doMoreStuff') ->then('explosion') ->then(null, function ($e) { echo "[Error]
{$e->getMessage()}\n"; });
Streams
Readable Writable
Readable Writable Through
Readable Writable Through Composite
Buffered Sink
Bi-directional
conn logger parser $conn->pipe($inputLogger)->pipe($parser);
parser client $parser->on('message', function ($message) use ($client) { $client->say('pong'); });
client conn logger $client->pipe($outputLogger)->pipe($conn);
conn parser client conn
Houston we have a blocking call
Inter-process communication
React/ZMQ
React/Stomp Predis/Async DNode-PHP
RealtimeWeb™
Ratchet
gifsockets!!!11
None
None
None
Thanks! • reactphp.org • @reactphp • @igorwesome