Skip to content

Instantly share code, notes, and snippets.

@ljmotta
Created October 14, 2020 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ljmotta/71ceeb26cc1fac1d679d584a44fccc2c to your computer and use it in GitHub Desktop.
Save ljmotta/71ceeb26cc1fac1d679d584a44fccc2c to your computer and use it in GitHub Desktop.
PingPongViewsPage
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