|
|
|
|
|
by deckyt
4861 days ago
|
|
Hi Bryan, Enjoyed your post. First-time posting here on HN so pardon any noobish remarks that follow ... I definitely like the idea of exposing webhook/subscriptions via REST in this way. Do you have any thoughts on how rich client-side apps (e.g. a Backbone app) could get the real-time benefits of such an API? It's my understanding that real-time updates will be POST-ed to a user-defined hook URL, presumably hosted on a server that is maintained by the API consumer. Maybe I've got it all wrong? Thanks again for your post. |
|
REST Hooks aren't really designed for browser consumption, you literally need a persistent connection to the browser to handle this.
For a quick example of a solution you could build: consider a Node server with Socket.IO. The client would work just like normal consuming REST APIs that return JSON, but the websocket would be an additional way to "update" the a Model or Collection in realtime.
Perhaps something like Redis' PUBSUB would work as the core mechanism (perhaps in your PHP/Python/Ruby app you'd save to the db, ping PUB into Redis, the Node instance would SUB out the message and send it to any clients). I am sure you could get sub-second reaction times this way.