Skip to content

Instantly share code, notes, and snippets.

@kevinswiber
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save kevinswiber/fb214c9cb84bcfdeec9f to your computer and use it in GitHub Desktop.

Select an option

Save kevinswiber/fb214c9cb84bcfdeec9f to your computer and use it in GitHub Desktop.
Latest example of Reactive Hypermedia Siren library consuming Zetta
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