when in doubt make it a property I guess
This commit is contained in:
@@ -14,12 +14,12 @@ import { createObservable, createObservableWithInit, cx } from "../fn";
|
||||
import { me } from "../profile";
|
||||
import Game from "./Game";
|
||||
import Player from "./Player";
|
||||
import { fromPromise } from "kefir";
|
||||
import { fromPromise, Stream } from "kefir";
|
||||
|
||||
export const TableContext = createContext<{
|
||||
players: Accessor<string[]>;
|
||||
view: Accessor<any>;
|
||||
sendWs: (msg: TWsIn) => void;
|
||||
wsEvents: Stream<TWsOut, any>;
|
||||
}>();
|
||||
|
||||
export default (props: { tableKey: string }) => {
|
||||
@@ -29,7 +29,6 @@ export default (props: { tableKey: string }) => {
|
||||
const ws = api.ws(props).subscribe();
|
||||
ws.on("open", () => res(ws));
|
||||
ws.on("error", () => res(ws));
|
||||
ws.on("close", () => res(ws));
|
||||
});
|
||||
|
||||
const sendWs = (msg: TWsIn) => wsPromise.then((ws) => ws.send(msg));
|
||||
@@ -39,7 +38,6 @@ export default (props: { tableKey: string }) => {
|
||||
onCleanup(() => wsPromise.then((ws) => ws.close()));
|
||||
|
||||
const presenceEvents = wsEvents.filter((evt) => evt.players != null);
|
||||
|
||||
const gameEvents = wsEvents.filter((evt) => evt.view != null);
|
||||
|
||||
const players = createObservableWithInit<string[]>(
|
||||
@@ -55,8 +53,8 @@ export default (props: { tableKey: string }) => {
|
||||
<TableContext.Provider
|
||||
value={{
|
||||
sendWs,
|
||||
wsEvents,
|
||||
view,
|
||||
players,
|
||||
}}
|
||||
>
|
||||
<div class="flex justify-around p-t-10">
|
||||
|
||||
Reference in New Issue
Block a user