Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
Make XHPAsync implement the XHPAwaitable trait
Browse files Browse the repository at this point in the history
Slightly reduces boilerplate, and it's just a marker interface.
  • Loading branch information
fredemmott committed Apr 22, 2015
1 parent 83d3daf commit 0f5a32c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/core/XHPAsync.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
*
*/

trait XHPAsync {

trait XHPAsync implements XHPAwaitable {
require extends :x:element;
require implements XHPAwaitable;

abstract protected function asyncRender(): Awaitable<XHPRoot>;

Expand Down
7 changes: 6 additions & 1 deletion tests/AsyncTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?hh

class :async:test extends :x:element implements XHPAwaitable {
class :async:test extends :x:element {
use XHPAsync;

protected async function asyncRender(): Awaitable<XHPRoot> {
Expand Down Expand Up @@ -39,4 +39,9 @@ public function testNestedWithNonAsyncChild() {
$xhp = <async:test><b>BE BOLD</b></async:test>;
$this->assertEquals('<div><b>BE BOLD</b></div>', $xhp->toString());
}

public function testInstanceOfInterface() {
$xhp = <async:test><b>BE BOLD</b></async:test>;
$this->assertInstanceOf(XHPAwaitable::class, $xhp);
}
}

0 comments on commit 0f5a32c

Please sign in to comment.