在第一个代码的帮助下,模型被加载,但是它们没有被加载到所需的文件中,并且看不到它们。它接受cookie中已经准备好的值,但是我需要它才能直接查看它。
subscriptions.js
function loadModel(model) {
return function(dispatch) {
dispatch(moveToPending(model))
const resource = require(`../resources/${model}`)
const resourceActions = bindActionCreators(resource.actions, dispatch)
const toaster = new Toaster(dispatch)
return new Promise((resolve, reject) => {
resourceActions[getFunctionName(model)]()
.then(res => {
resolve(model)
dispatch(resolveSubscriptions(model))
})
.catch(err => {
if (debug) console.error(err)
reject({ ...err, model })
dispatch(resolveSubscriptions(model))
toaster.error(`Could not load ${model}!`)
})
})
}
}
charts.js
export default class Charts extends Component {
constructor(props) {
super(props);
this.types = ['Revenue', 'Cost'],
this.toaster = props.actions.toaster();
this.subscriptions = ['articles'],
this.state = this.createInitialState()
}