gritzko / swarm

JavaScript replicated model (M of MVC) library
http://swarmdb.net/
MIT License
2.68k stars 97 forks source link

Relay is comming #59

Open tychotatitscheff opened 9 years ago

tychotatitscheff commented 9 years ago

After seeing this keynote from @vjeux at React Europe, I think that It could be possible to make swarm works with relay.

For the one who have never heard of it, relay is a module that allow you to declare requirement inside the components and will handle for you the unirectional data flow in a much simpler way than flux.

See the FAQ for more info.

Basically im not sure how rellay and swarm can work together since most of the feature are shared but swarm has the advantage of beeing able to do real time and persistency (cf keynote) and i never heard that rellay aims to do it.

It may be a good idea to look at rellay once it is released in order to see if it would be possible to make something with with { relay + swarmjs }.

vjeux commented 9 years ago

Cc @joesavona

tychotatitscheff commented 9 years ago

The real account is @josephsavona isn't it ?

gritzko commented 9 years ago

Tycho, thanks for the hint.

Real-time and persistence are indeed two very hard challenges and Swarm focuses exactly on those two things. This ice-and-fire trade-off (real-time + offline-ready) is mostly motivated by collaborative/social apps and mobile devices. More on objectives: http://swarmjs.github.io/articles/1of5/

It takes a novel architecture to sort those things out. Swarm employs op-based CRDTs, automatic merge of changes, continuous sync, all-async interfaces, etc.

Technically, it syncs over WebSocket and caches data in WebStorage or IndexedDB. It has its own data sync protocol (Lamport timestamps and all that stuff).

Hence, Swarm is not something you can easily slap on an existing system.

Still, I see the obvious Swarm/Relay overlap. That is a centralized data store, unified data fetching/syncing, event flow.

Compared to Relay, Swarm is hardcore on real-time and offline/caching. But, it lacks in object graph management, GraphQL and related things. Which is definitely nice to have (and often requested).

In case Relay would allow for pluggable backends in a non-trivial way, then probably it is possible to carve something out.

So far, React integration was a breeze because basic abstractions match really well.