| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview Defines StoreClient, a Polymer behavior to tie a front-end | 6 * @fileoverview Defines StoreClient, a Polymer behavior to tie a front-end |
| 7 * element to back-end data from the store. | 7 * element to back-end data from the store. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 cr.define('bookmarks', function() { | 10 cr.define('bookmarks', function() { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // TODO(tsergeant): Warn if localProperty is not a defined property. | 52 // TODO(tsergeant): Warn if localProperty is not a defined property. |
| 53 this.watches_.push({ | 53 this.watches_.push({ |
| 54 localProperty: localProperty, | 54 localProperty: localProperty, |
| 55 valueGetter: valueGetter, | 55 valueGetter: valueGetter, |
| 56 }); | 56 }); |
| 57 }, | 57 }, |
| 58 | 58 |
| 59 /** | 59 /** |
| 60 * Helper to dispatch an action to the store, which will update the store | 60 * Helper to dispatch an action to the store, which will update the store |
| 61 * data and then (possibly) flow through to the UI. | 61 * data and then (possibly) flow through to the UI. |
| 62 * @param {Action} action | 62 * @param {?Action|DeferredAction} action |
| 63 */ | 63 */ |
| 64 dispatch: function(action) { | 64 dispatch: function(action) { |
| 65 bookmarks.Store.getInstance().handleAction(action); | 65 bookmarks.Store.getInstance().handleAction(action); |
| 66 }, | 66 }, |
| 67 | 67 |
| 68 /** @param {string} newState */ | 68 /** @param {string} newState */ |
| 69 onStateChanged: function(newState) { | 69 onStateChanged: function(newState) { |
| 70 this.watches_.forEach(function(watch) { | 70 this.watches_.forEach(function(watch) { |
| 71 var oldValue = this[watch.localProperty]; | 71 var oldValue = this[watch.localProperty]; |
| 72 var newValue = watch.valueGetter(newState); | 72 var newValue = watch.valueGetter(newState); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 89 /** @return {!BookmarksPageState} */ | 89 /** @return {!BookmarksPageState} */ |
| 90 getState: function() { | 90 getState: function() { |
| 91 return bookmarks.Store.getInstance().data; | 91 return bookmarks.Store.getInstance().data; |
| 92 }, | 92 }, |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 return { | 95 return { |
| 96 StoreClient: StoreClient, | 96 StoreClient: StoreClient, |
| 97 }; | 97 }; |
| 98 }); | 98 }); |
| OLD | NEW |