Skip to content

Instantly share code, notes, and snippets.

@coodoo
Created August 6, 2018 08:11
Show Gist options
  • Save coodoo/3b1cf4d463d08ab984b79717a0908f63 to your computer and use it in GitHub Desktop.
Save coodoo/3b1cf4d463d08ab984b79717a0908f63 to your computer and use it in GitHub Desktop.
How to write fat arrow function.
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