1 | import { DataStore } from './dataStore'
|
2 | import { Component } from '../lib/component'
|
3 |
|
4 | export class DataStoreComponent extends Component {
|
5 | /**
|
6 | * @typedef {Object.<string, any>} Props
|
7 | * @property {DataStore} Props.dataStore
|
8 | * @param {Props} props
|
9 | */
|
10 | constructor(props) {
|
11 | super(props)
|
12 | /**
|
13 | * @property {DataStore} dataStore
|
14 | */
|
15 | this.dataStore = /** @type {DataStore}*/(props.dataStore)
|
16 | if (props.dataStore instanceof DataStore) {
|
17 | props.dataStore.watch('dataStoreStateChanged', () => this.update(this.dataStore.state))
|
18 | }
|
19 | }
|
20 | }
|