Skip to content

Commit

Permalink
Require Datastar 0.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Oct 18, 2024
1 parent 544cdef commit 850cbc3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This plugin is licensed for free under the MIT License.

## Requirements

This plugin requires Datastar 0.19.0 or later and PHP 8.0.0 or later.
This plugin requires Datastar 0.19.3 or later and PHP 8.0.0 or later.

## Installation

Expand Down Expand Up @@ -55,9 +55,10 @@ $event->content = '/new-url';
$event->id = 1;

$event = new ConsoleEvent();
$event->content = 'log Hello world';
$event->content = 'Hello world';
// Optional
$event->id = 1;
$event->mode = 'error';

// Returns the output of a Datastar event.
$output = $event->getOutput();
Expand Down
5 changes: 3 additions & 2 deletions src/events/ConsoleEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ class ConsoleEvent implements EventInterface
use EventTrait;

public string $content = '';
public string $mode = 'log';

/**
* @inerhitdoc
*/
public function getOutput(): string
{
$output = ['data: ' . $this->content];
$output = ['data: ' . $this->mode . ' ' . $this->content];

return $this->getEventOutput('redirect', $output);
return $this->getEventOutput('console', $output);
}
}
2 changes: 1 addition & 1 deletion src/events/DeleteEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public function getOutput(): string
{
$output = ['data: selector ' . $this->selector];

return $this->getEventOutput('redirect', $output);
return $this->getEventOutput('delete', $output);
}
}

0 comments on commit 850cbc3

Please sign in to comment.