mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 02:07:54 +00:00
Migrate more components to use mixin
This commit is contained in:
parent
791ebff7ee
commit
dcffd102cc
@ -30,20 +30,25 @@
|
|||||||
|
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
var storeListenerMixIn = window.hass.storeListenerMixIn;
|
||||||
loaded: window.hass.syncStore.initialLoadDone(),
|
|
||||||
|
Polymer(Polymer.mixin({
|
||||||
|
loaded: false,
|
||||||
|
|
||||||
ready: function() {
|
ready: function() {
|
||||||
// remove the HTML init message
|
// remove the HTML init message
|
||||||
document.getElementById('init').remove();
|
document.getElementById('init').remove();
|
||||||
|
|
||||||
// listen if we are fully loaded
|
this.listenToStores(true);
|
||||||
window.hass.syncStore.addChangeListener(this.updateLoadStatus.bind(this));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
updateLoadStatus: function() {
|
detached: function() {
|
||||||
this.loaded = window.hass.syncStore.initialLoadDone();
|
this.stopListeningToStores();
|
||||||
},
|
},
|
||||||
});
|
|
||||||
|
syncStoreChanged: function(syncStore) {
|
||||||
|
this.loaded = syncStore.initialLoadDone();
|
||||||
|
},
|
||||||
|
}, storeListenerMixIn));
|
||||||
</script>
|
</script>
|
||||||
</polymer-element>
|
</polymer-element>
|
||||||
|
@ -31,32 +31,31 @@
|
|||||||
</partial-base>
|
</partial-base>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
Polymer({
|
var storeListenerMixIn = window.hass.storeListenerMixIn;
|
||||||
|
var stateHistoryActions = window.hass.stateHistoryActions;
|
||||||
|
|
||||||
|
Polymer(Polymer.mixin({
|
||||||
stateHistory: null,
|
stateHistory: null,
|
||||||
|
|
||||||
ready: function() {
|
ready: function() {
|
||||||
this.stateHistoryStoreChanged = this.stateHistoryStoreChanged.bind(this);
|
this.listenToStores(true);
|
||||||
|
|
||||||
window.hass.stateHistoryStore.addChangeListener(this.stateHistoryStoreChanged);
|
|
||||||
|
|
||||||
if (window.hass.stateHistoryStore.isStale()) {
|
|
||||||
window.hass.stateHistoryActions.fetchAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.stateHistoryStoreChanged();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
detached: function() {
|
detached: function() {
|
||||||
window.hass.stateHistoryStore.removeChangeListener(this.stateHistoryStoreChanged);
|
this.stopListeningToStores();
|
||||||
},
|
},
|
||||||
|
|
||||||
stateHistoryStoreChanged: function() {
|
stateHistoryStoreChanged: function(stateHistoryStore) {
|
||||||
this.stateHistory = window.hass.stateHistoryStore.all();
|
if (stateHistoryStore.isStale()) {
|
||||||
|
stateHistoryActions.fetchAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.stateHistory = stateHistoryStore.all();
|
||||||
},
|
},
|
||||||
|
|
||||||
handleRefreshClick: function() {
|
handleRefreshClick: function() {
|
||||||
window.hass.stateHistoryActions.fetchAll();
|
stateHistoryActions.fetchAll();
|
||||||
},
|
},
|
||||||
});
|
}, storeListenerMixIn));
|
||||||
</script>
|
</script>
|
||||||
</polymer>
|
</polymer>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user