Created
August 6, 2018 08:11
-
-
Save coodoo/3b1cf4d463d08ab984b79717a0908f63 to your computer and use it in GitHub Desktop.
How to write fat arrow function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io from 'socket.io-client' | |
const A = require('automerge') | |
const foo = bar => { | |
bar.map( b => b.title ) | |
} | |
startConnection() { | |
this.socket = io('http://localhost:5000') | |
this.socket.on('init', this.initConnection) | |
this.socket.on('change', this.applyRemoteUpdates) | |
} | |
applyRemoteUpdates = ch => { | |
if (ch.length == 0) return | |
const changes = ch.filter(itm => itm.actor !== this.core.replica._actorId) | |
if (changes.length == 0) { | |
return | |
} | |
const newDoc = A.applyChanges(this.core.replica, changes) | |
this.core.replica = newDoc | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment