Created
August 11, 2015 22:39
-
-
Save lemesdaniel/c922a4732f446aa01693 to your computer and use it in GitHub Desktop.
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
var app = new Vue({ | |
el: '#list', | |
data: { | |
posts: [ | |
{ | |
title: 'Como integrar o fanout com laravel' | |
}, | |
] | |
} | |
}) | |
var add = new Vue({ | |
el: '#add', | |
data: { | |
title: '', | |
msg: '' | |
}, | |
methods: { | |
addPost: function(e) { | |
e.preventDefault(); | |
if (!this.title) return; | |
$.post('/novo', { title: this.title }); | |
this.title = ''; | |
this.msg = 'Adicionado com sucesso'; | |
} | |
} | |
}) | |
var client = new Faye.Client('http://9b1cf4d8.fanoutcdn.com/bayeux'); | |
client.subscribe('/test', function (item) { | |
app.posts.push({ title: item.data.message }) | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment