From 16de86a07d156dcd675047198be6273f7dbeadfa Mon Sep 17 00:00:00 2001 From: Nick Van Doorn Date: Sat, 2 Mar 2019 16:28:36 -0800 Subject: Stringify only once --- server/src/server.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/src/server.ts b/server/src/server.ts index 1cb441b..0973518 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -21,8 +21,13 @@ export const runServer = async (ctx: Context): Promise => { ctx, db, async (dbChange: DatabaseChange) => { + const changeBuff = JSON.stringify(dbChange) + // TODO figure out if `client` cares about + // `dbChange` instead of just assuming that + // `client` cares because `subscribe` has been + // called at least once for (let client of wss.clients) { - client.send(JSON.stringify(dbChange)) + client.send(changeBuff) } } ) -- cgit v1.2.3