diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/debugger/new/test/mochitest/examples/long.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/debugger/new/test/mochitest/examples/long.js')
-rw-r--r-- | devtools/client/debugger/new/test/mochitest/examples/long.js | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/devtools/client/debugger/new/test/mochitest/examples/long.js b/devtools/client/debugger/new/test/mochitest/examples/long.js new file mode 100644 index 000000000..58d605b36 --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/long.js @@ -0,0 +1,76 @@ +var app = {}; + +// Generic "model" object. You can use whatever +// framework you want. For this application it +// may not even be worth separating this logic +// out, but we do this to demonstrate one way to +// separate out parts of your application. +app.TodoModel = function (key) { + this.key = key; + this.todos = []; + this.onChanges = []; +}; + +app.TodoModel.prototype.addTodo = function (title) { + this.todos = this.todos.concat([{ + id: Utils.uuid(), + title: title, + completed: false + }]); +}; + +app.TodoModel.prototype.inform = function() { + // Something changed, but we do nothing + return null; +}; + +app.TodoModel.prototype.toggleAll = function (checked) { + // Note: it's usually better to use immutable data structures since they're + // easier to reason about and React works very well with them. That's why + // we use map() and filter() everywhere instead of mutating the array or + // todo items themselves. + this.todos = this.todos.map(function (todo) { + return Object.assign({}, todo, {completed: checked}); + }); + + this.inform(); +}; + +app.TodoModel.prototype.toggle = function (todoToToggle) { + this.todos = this.todos.map(function (todo) { + return todo !== todoToToggle ? + todo : + Object.assign({}, todo, {completed: !todo.completed}); + }); + + this.inform(); +}; + +app.TodoModel.prototype.destroy = function (todo) { + this.todos = this.todos.filter(function (candidate) { + return candidate !== todo; + }); + + this.inform(); +}; + +app.TodoModel.prototype.save = function (todoToSave, text) { + this.todos = this.todos.map(function (todo) { + return todo !== todoToSave ? todo : Object.assign({}, todo, {title: text}); + }); + + this.inform(); +}; + +app.TodoModel.prototype.clearCompleted = function () { + this.todos = this.todos.filter(function (todo) { + return !todo.completed; + }); + + this.inform(); +}; + +function testModel() { + const model = new app.TodoModel(); + model.clearCompleted(); +} |