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

Unified Diff: chrome/browser/resources/md_bookmarks/bookmarks_store.js

Issue 2745993002: MD Bookmarks: Update URL router to work in new data binding system (Closed)
Patch Set: calamity@ review 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/md_bookmarks/bookmarks_store.js
diff --git a/chrome/browser/resources/md_bookmarks/bookmarks_store.js b/chrome/browser/resources/md_bookmarks/bookmarks_store.js
index 78fa60ac49bdeadb8b8101349f04b71a8532a2c8..077c6db535a2412f8e49c40e9861f914579a0300 100644
--- a/chrome/browser/resources/md_bookmarks/bookmarks_store.js
+++ b/chrome/browser/resources/md_bookmarks/bookmarks_store.js
@@ -15,6 +15,8 @@ cr.define('bookmarks', function() {
this.data_ = bookmarks.util.createEmptyState();
/** @type {boolean} */
this.initialized_ = false;
+ /** @type {!Array<!Action>} */
+ this.queuedActions_ = [];
/** @type {!Array<!StoreObserver>} */
this.observers_ = [];
}
@@ -25,6 +27,11 @@ cr.define('bookmarks', function() {
*/
init: function(initialState) {
this.data_ = initialState;
+
+ this.queuedActions_.forEach(function(action) {
+ this.reduce_(action);
+ }.bind(this));
+
this.initialized_ = true;
this.notifyObservers_(this.data_);
},
@@ -52,18 +59,29 @@ cr.define('bookmarks', function() {
/**
* Transition to a new UI state based on the supplied |action|, and notify
- * observers of the change.
+ * observers of the change. If the Store has not yet been initialized, the
+ * action will be queued and performed upon initialization.
* @param {Action} action
*/
handleAction: function(action) {
- if (!this.initialized_)
+ if (!this.initialized_) {
+ this.queuedActions_.push(action);
return;
+ }
- this.data_ = bookmarks.reduceAction(this.data_, action);
+ this.reduce_(action);
this.notifyObservers_(this.data_);
},
/**
+ * @param {Action} action
+ * @private
+ */
+ reduce_: function(action) {
+ this.data_ = bookmarks.reduceAction(this.data_, action);
+ },
+
+ /**
* @param {!BookmarksPageState} state
* @private
*/
« no previous file with comments | « chrome/browser/resources/md_bookmarks/app.html ('k') | chrome/browser/resources/md_bookmarks/compiled_resources2.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698