Last active
August 29, 2015 14:10
-
-
Save kevinswiber/fb214c9cb84bcfdeec9f to your computer and use it in GitHub Desktop.
Latest example of Reactive Hypermedia Siren library consuming Zetta
This file contains hidden or 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 Rx = require('rx'); | |
| var siren = require('siren'); | |
| var display = new Rx.Subject(); | |
| siren() | |
| .load('http://zetta-cloud-2.herokuapp.com') | |
| .link('http://rels.zettajs.io/peer', 'Detroit') | |
| .entity(function(e) { | |
| return e.properties.type === 'display'; | |
| }) | |
| .subscribe(display); | |
| siren(display) | |
| .action('change', function(action) { | |
| action.set('message', 'Hello world: ' + Date.now()); | |
| return action.submit(); | |
| }) | |
| .subscribe(function(env) { | |
| console.log(env.response.statusCode); | |
| }); | |
| siren(display) | |
| .link('http://rels.zettajs.io/object-stream', 'message') | |
| .monitor() | |
| .take(1) | |
| .subscribe(console.log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment