View page-reducer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const fanSpeedInitial = { | |
level: 0, | |
status: 'OFF' | |
}; | |
export const ROTATE_RIGHT_ACTION = | |
{ type: 'ROTATE_RIGHT' }; | |
export const ROTATE_LEFT_ACTION = | |
{ type: 'ROTATE_LEFT' } | |
export function fanSpeedReducer(fanSpeed: any, action: any) { | |
if (action.type == 'ROTATE_RIGHT') { |
View page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use client"; | |
import { useReducer } from "react"; | |
import { fanSpeedInitial, fanSpeedReducer } from "./page-reducer"; | |
export default function Home() { | |
const [fanSpeedCurrent, fanSpeedHandler] = useReducer(fanSpeedReducer, fanSpeedInitial); | |
return ( | |
<main style={{ padding: 20 }}> | |
<div> |
View resources\views\livewire\calculator.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div style="background: #aaffcc;padding:20;width:240px"> | |
<h5>Calculator Component</h5> | |
<form wire:submit.prevent="multiply"> | |
First<br/> | |
<input type="text" wire:model="n1" /> | |
<br/> | |
@error('n1') | |
{{ $message }} | |
@enderror | |
<br/>Second<br/> |
View resources\views\livewire\receiver.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div style="background: #ffaacc;padding:20;width:240px"> | |
<h5>Receiver</h5> | |
{{$message}} {{$timeStamp}} | |
</div> |
View App\Http\Livewire\Receiver.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Livewire; | |
use Livewire\Component; | |
class Receiver extends Component | |
{ | |
public $message="Received no event so far"; | |
public $timeStamp=''; |
View resources\views\livewire\sender.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div style="background: #aaccff;padding:20;width:240px"> | |
<h5>Sender</h5> | |
<button wire:click="fireTimestampEvent()">Gnerate Event </button> | |
</div> |
View App\Http\Livewire\Sender.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Livewire; | |
use Livewire\Component; | |
class Sender extends Component | |
{ | |
public function fireTimestampEvent() | |
{ |
View App\Http\Livewire\Calculator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Livewire; | |
use Livewire\Component; | |
class Calculator extends Component | |
{ | |
public $n1; | |
public $n2; |
View welcome.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
@livewireStyles | |
@livewireScripts | |
</head> | |
<body> | |
<livewire:inventors /> | |
</body> |
View inventors.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<select wire:model="invention"> | |
@foreach ($list as $k => $v) | |
<option value="{{ $k }}">{{ $k }}</option> | |
@endforeach | |
</select> invented by | |
{{ $inventor }} | |
</div> |
NewerOlder