jschoch / reflux_eventbroker_react_phoenix_elixir

Using Reflux to broker events with React and Phoenix
MIT License
5 stars 0 forks source link

Also interested in React, websockets etc #1

Open houshuang opened 9 years ago

houshuang commented 9 years ago

Hi Jesse, didn't know where else to reach you, so leaving a message here. Just wanted to mention that I've also been interested in mixing React and Phoenix+Websockets. I wrote a simple app for real-time meetings (first image here) http://imgur.com/a/rAXVz, where I just send operations directly to the websocket, and state is just a map that gets pushed back to all clients. It worked well for a few chats with 80+ participants.

Currently I'm thinking about making this more efficient. I've been working on a json patch library to only send the diff over the wire (not quite done yet: https://github.com/houshuang/diffmatch/blob/master/lib/diffmatch.ex), and also thought about using macros to make writing "reducers" over state very terse (inspired by reading about Redux). This currently works from a macro level: https://github.com/houshuang/diffmatch/blob/master/lib/ops.ex - basically I need the gen_server that keeps state, and calls this on the state whenever a new op is received from the client, pushes out a diff of the updated state etc. THe idea is that I will just store the ops in a persistent database, and at anytime be able to reconstruct state by reducing over the ops (or even go back in time - those providing time machine capability based on server-stored state, kind of like Etherpad).

jschoch commented 9 years ago

seems like garbage collection is the tough problem in this space.

http://www.xaprb.com/blog/2013/12/28/immutability-mvcc-and-garbage-collection/

not likely to be a problem for a small chat app though