Created
October 14, 2020 20:58
-
-
Save ljmotta/71ceeb26cc1fac1d679d584a44fccc2c to your computer and use it in GitHub Desktop.
PingPongViewsPage
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 { PingPongChannelApi } from "ping-pong-view/dist/api"; | |
let pings = 0; | |
let pongs = 0; | |
export function PingPongViewsPage() { | |
const [lastPing, setLastPing] = useState<string>("-"); | |
const [lastPong, setLastPong] = useState<string>("-"); | |
const api: PingPongChannelApi = useMemo(() => { | |
return { | |
pingPongView__ping(source: string) { | |
pings++; | |
setLastPing(source); | |
}, | |
pingPongView__pong(source: string, replyingTo: string) { | |
pongs++; | |
setLastPong(source); | |
}, | |
}; | |
}, [pings, pongs]); | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment