Skip to content

Commit

Permalink
Merge pull request #6 from PUBLIQNetwork/asyncReact
Browse files Browse the repository at this point in the history
Async react
  • Loading branch information
vazgen authored Sep 11, 2017
2 parents 1599b9a + a2e6c08 commit 1ffd6ff
Show file tree
Hide file tree
Showing 9 changed files with 656 additions and 114 deletions.
52 changes: 40 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@
$esApiConnector = new ApiConnector('your_api_key');
$etherScan = new EtherScan($esApiConnector);
echo $etherScan->getAccount(EtherScan::PREFIX_API)->getTransactions('0xbb9bc244d798123fde783fcc1c72d3bb8c189413', 1) . PHP_EOL;
echo $etherScan->getTxLink('0x14dc46124c7cc003c158eb6ba812b2f53d509753fd931607edad957504d19bd3');
echo "END OF FILE" . PHP_EOL;
$account = $etherScan->getAccount(EtherScan::PREFIX_API);
$startT = microtime(1);
echo $account->getTransactions('0xbb9bc244d798123fde783fcc1c72d3bb8c189413', 1, 25, 'desc') . PHP_EOL;
echo $account->getTransactions('0xbb9bc244d798123fde783fcc1c72d3bb8c189413', 1, 25, 'desc') . PHP_EOL;
echo $account->getTransactions('0xbb9bc244d798123fde783fcc1c72d3bb8c189413', 1, 25, 'desc') . PHP_EOL;
echo $account->getTransactions('0xbb9bc244d798123fde783fcc1c72d3bb8c189413', 1, 25, 'desc') . PHP_EOL;
$endT = microtime(1);
echo "DONE IN: " . ($endT - $startT);
```

</li>
Expand All @@ -20,16 +28,36 @@ echo "END OF FILE" . PHP_EOL;
```
$esApiConnector = new ApiConnector('your_api_key');
$etherScan = new EtherScan($esApiConnector);
$a = function ($responseOnResolve) {
echo 'Called on resolve: ' . $responseOnResolve . PHP_EOL;
};
$b = function ($responseOnResolve) {
echo 'Called on error: ' . $responseOnResolve . PHP_EOL;
};
$account = $etherScan->getAccount(EtherScan::PREFIX_API);
$startT = microtime(1);
$etherScan->callGroupAsync([
[
$account->getTransactionsLink('0xbb9bc244d798123fde783fcc1c72d3bb8c189413', 1, 25, Account::SORT_DESC),
$a, $b
],
[
$account->getTransactionsLink('0xbb9bc244d798123fde783fcc1c72d3bb8c189413', 1, 25, Account::SORT_DESC),
$a, $b
],
[
$account->getBalanceLink('0xbb9bc244d798123fde783fcc1c72d3bb8c189413'),
$a, $b
],
[
$account->getTransactionsLink('0xbb9bc244d798123fde783fcc1c72d3bb8c189413', 1, 25, Account::SORT_DESC),
$a, $b
],
]);
$endT = microtime(1);
echo $etherScan->getStats(EtherScan::PREFIX_API)->getEthPriceAsync(
function ($responseOnResolve) {
echo 'Called on resolve: ' . $responseOnResolve . PHP_EOL;
},
function ($responseOnReject) {
echo 'Called on reject: ' . $responseOnReject . PHP_EOL;
}
);
echo "END OF FILE" . PHP_EOL;
echo "DONE IN: " . ($endT - $startT);
```

</li>
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"minimum-stability": "stable",
"require": {
"php": "^7.0",
"guzzlehttp/promises": "^1.3"
"react/promise": "^2.5",
"react/event-loop": "^0.4.3",
"react/http-client": "^0.5.4"
},
"require-dev": {
"phpunit/phpunit": "^6.3"
Expand Down
Loading

0 comments on commit 1ffd6ff

Please sign in to comment.