• Stars
    star
    316
  • Rank 132,587 (Top 3 %)
  • Language
    JavaScript
  • License
    Creative Commons ...
  • Created over 8 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Sync Redux apps peer to peer over WebRTC via Swarmlog

Redux Swarmlog

travis build version

Video

(Click image to watch React Europe lightning video)

ScreenShot

(Click image to watch Egghead.io intro video)

A super simple way of writing distributed Redux applications. The Redux action log is persisted in an IndexDB and synced with other peers via a WebRTC Swarm using Swarmlog.

When an application reloads the Redux store is initialsed by reducing all the persisted actions in the IndexDB and syncing any new actions from remote peers. Watch the Egghead video above to find out more.

Pros

  • offline data by default
  • super simple mental model for writing distributed apps
  • UIs update automatically as remote actions come in
  • works offline by default
  • scales globally for free with no bandwidth or storage costs for the developer
  • the developer is not responsible for client data
  • friends not cooperations hold user data
  • public / private key authentication is lighter weight than user accounts
  • time travel

Cons

  • Action logs use more bandwidth than raw data so initial sync could be slow for a very long log.

workaround: Break down long logs into lots of smaller logs e.g. log per month, week or day. Only fetch the most recent log if its all thats needed

  • Extra storage space needed on client

workaround: The price of SSDs is falling very rapidly. Stop thinking about cloud and thin client, but cache encrypted data where it is needed. This gives privacy, enables working offline, provides backups and can act as a CDN. Once you start using a distributed system like Git you soon stop thinking about the extra space it requires.

  • Permanence: even if an action deletes an item it can still be retrieved from the log.

workaround: Use a log for versioning other logs. Every so often the main log is reduced and a single action is written to a new log which creates the store in the current state. The old log is marked as stale in the version log and its database is deleted (purging old actions).

  • Can't get most up to date data if the peer holding it is offline

workaround: A small device like a Raspberry PI kept online should be all that is needed to make sure there is always at least one up to date source of truth. With 5G and IoT we are heading towards an era of always online small connected devices. Let's start thinking that way now.

Play to Strengths

Redux Swarmlog works well for apps that support some kind of physical live event. Because you know the action log will be short and the users will be online at the same time. Examples might be providing subtitles via mobile phone for a theatre show or letting a teacher see in realtime how each individuals in a class is answering a question.

More Repositories

1

subdivide

Split pane layout system for React. Each pane can be subdivided and any widget assigned to any pane allowing users to define layout.
JavaScript
435
star
2

react-bible

as you type bible search
JavaScript
14
star
3

react-project-archetype

Template for new React projects (Webpack 2, Babel 6, Flow, AirBnB eslint)
JavaScript
8
star
4

bible-references

JavaScript
6
star
5

todomvc-redux-swarmlog

JavaScript
6
star
6

recompose-theme

Theme with Recompose and React
JavaScript
5
star
7

filter-edit-table-example

JavaScript
5
star
8

song-display

Display song lyrics on a canvas such that text is as large as possible
JavaScript
4
star
9

component-boilerplate

Build test and publish react components
JavaScript
4
star
10

react-iframe-bind

Sharing components between iframes
JavaScript
3
star
11

song-fit

Fit each verse of a song to the requested aspect ratio on an HTML5 canvas
JavaScript
2
star
12

simpleRedux

creates actions, constants and reducers for dumb actions
JavaScript
2
star
13

hymnsheet

Decentralised worship
Svelte
2
star
14

functional-styles

JavaScript
1
star
15

googlish

JavaScript
1
star
16

bible

Bibles in various formats served as GitHub Pages
1
star
17

Fireflies

JavaScript
1
star
18

reason-counter-rest-client

Minimal Reason rest app
JavaScript
1
star
19

back-to-the-present

optimistic reducer for multiplayer games
JavaScript
1
star
20

reason-web-starterkit

Start writing your web applications using reason+bucklescript
JavaScript
1
star
21

color-array

Functional color conversion between CSS strings and rgba arrays
JavaScript
1
star
22

svelte-song-display

Display responsive lyrics
JavaScript
1
star