In the home function we are grabbing the timestamp for the updates queue and pass that to the view so that we know the time to pass when we start polling for updates. Create the todo model todo/src/model/todo.erl-module(todo, [Id, Text, Order, Done]).
-compile(export_all).

after_create() ->
boss_mq:push(“updates”, THIS).

after_update() ->
boss_mq:push(“updates”, THIS).

This is just a simple model that on save and update pushes that information to the boss_mq Now lets create the controller to handle the polling todo/src/controller/todo_poll_controller.erl-module(todo_poll_controller, [Req, SessionId]).
-compile(export_all).

Here we just have one action that waits for something to be pushed to the message, when it gets a new object it returns it along with the timestamp. Now lets create the restful controller to handle the todos todo/src/controller/todo_todos_controller.erl-module(todo_todos_controller, [Req, SessionId]).
-compile(export_all).
-default_action(index).

index(‘GET’, []) ->
%% Get all of the todos and output a json list of them
Todos = boss_db:find(todo,[]),
{json, Todos};

This is just a standard rest interface to the todos. Finally lets make a few changes to todo/priv/static/js/todos.js// An example Backbone application contributed by
// [Jérôme Gravel-Niquet](http://jgn.me/). This demo uses a simple
// [LocalStorage adapter](backbone-localstorage.html)
// to persist Backbone models within your browser.

// Load the application once the DOM is ready, using `jQuery.ready`:
$(function(){

// Filter down the list to only todo items that are still not finished.
remaining: function() {
return this.without.apply(this, this.done());
},

// We keep the Todos in sequential order, despite being saved by unordered
// GUID in the database. This generates the next order number for new items.
nextOrder: function() {
if (!this.length) return 1;
return this.last().get(‘order’) + 1;
},

// To avoid XSS (not that it would be harmful in this particular app),
// we use `jQuery.text` to set the contents of the todo item.
setText: function() {
var text = this.model.get(‘text’);
this.$(‘.todo-text’).text(text);
this.input = this.$(‘.todo-input’);
this.input.bind(‘blur’, _.bind(this.close, this)).val(text);
},

// Toggle the `”done”` state of the model.
toggleDone: function() {
this.model.toggle();
},

// At initialization we bind to the relevant events on the `Todos`
// collection, when items are added or changed. Kick things off by
// loading any preexisting todos that might be saved in *localStorage*.
initialize: function() {
this.input = this.$(“#new-todo”);

You should be ready to start the app now 🙂 ** Right now there is a problem with the destructure_json stuff and it will fail if you dont make the project before running start-dev.sh I am looking into this, but for now just run make 🙂
$ cd todo
$ make
$ ./start-dev.sh