Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/test/data/webui/md_bookmarks/test_store.js

Issue 2704983002: MD Bookmarks: Proof-of-concept reimplementation of data storage/binding layer (Closed)
Patch Set: Add doc comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 cr.define('bookmarks', function() {
6 var TestStore = function(data) {
7 this.data = Object.assign(bookmarks.util.createEmptyState(), data);
8 this.actions_ = [];
9 this.observers_ = [];
10 };
11
12 TestStore.prototype = {
13 addObserver: function(client) {
14 this.observers_.push(client);
15 },
16
17 removeObserver: function(client) {},
18
19 isInitialized: function() {
20 return true;
21 },
22
23 handleAction: function(action) {
24 this.actions_.push(action);
25 },
26
27 get lastAction() {
28 return this.actions_[this.actions_.length - 1];
29 },
30
31 notifyObservers: function() {
32 // For simplicity, we don't want tests to have to worry about modifying
33 // the whole state tree when they want to change a single property. An
34 // alternative is to perform a deep clone in here.
35 this.observers_.forEach((client) => client.onStateChanged(this.data));
36 },
37 };
38
39 return {
40 TestStore: TestStore,
41 };
42 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/store_test.js ('k') | chrome/test/data/webui/md_bookmarks/test_util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698