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
import { query } from "@prodo/firebase-plugins"; | |
function ChatApp({}) { | |
const { db, state } = useData(); | |
const messages = query(db.messages).where("room", "==", state.roomId); | |
return ( | |
<div> | |
<RoomSelector /> | |
{messages.map(({ key }) => ( | |
<Message id={key} /> |
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
function PostMessage() { | |
const { postMessage } = useActions(); | |
return ( | |
<input | |
placeholder="say something nice" | |
onKeyUp={e => { | |
if (e.keyCode === 13 /* enter */) { | |
postMessage(e.target.value); | |
} | |
}} |
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
function RoomSelector() { | |
const { state } = useData(); | |
const { setRoom } = useActions(); | |
return ( | |
<input | |
value={state.roomId} | |
onChange={e => { | |
setRoom(e.target.value); | |
}} | |
/> |
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
function Message({ id }) { | |
const { db } = useData(); | |
const { likeMessage } = useActions(); | |
return ( | |
<div> | |
<h2>{db.messages[id].text}</h2> | |
<span>{db.messages[id].likes}</span> | |
<button onClick={() => likeMessage(id)}>+1</button> | |
</div> | |
); |
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
import { useData } from "./data"; | |
import { useActions } from "./actions"; |
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
import { actionsProxy, memo } from "@prodo/core"; | |
import { db, state, auth } from "./data"; | |
import { newId } from "./effects" | |
function setRoom(id: string) { | |
state.roomId = id; | |
} | |
function likeMessage(id: string) { | |
db.messages[id].likes++; | |
} |
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
import { dataModel } from "@prodo/core"; | |
import { authPlugin, dbPlugin } from "@prodo/firebase-plugins"; | |
const data = dataModel<{ | |
state: { | |
roomId: string; | |
message: string; | |
}; | |
auth: { | |
username: string; |
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 Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
// ************************************ | |
// * YASPER: Yet Another Speed Reader * | |
// ************************************ | |
// This is a Tampermonkey script for speed-reading in Chrome. | |
// Configure the list of matched pages as usual (default = @match http*://*.wikipedia.org/*). | |
// Whenever a sentence of paragraph is selected, a single-world speed reader pops up below the cursor. | |
// Typical usage: triple-click on the first word of a paragraph to start speed-reading it. | |
// Tip 1: read the first few words of the paragraph before triple-clicking. | |
// Tip 2: for more efficiency, start scrolling down to the next paragraph while speed-reading. |