Open huqianghui opened 8 years ago
When I trigger the action to add domain object, why this refer to Alt, not the PolicyStore?
Below is my code.
app.js
var Alt = require('alt'); //console.log(Alt) var alt = new Alt();
module.exports = alt;
my Action: import alt from '../app'; class PolicyActions { addDomainObject(modelName, objectCode, scopeObject) { var payload = {}; payload.modelName = modelName; payload.objectCode = objectCode; payload.scopeObject = scopeObject; this.dispatch(payload); } }
module.exports = alt.createActions(PolicyActions);
myStore
import alt from '../app'; class PolicyStore { constructor() { let policy = {}; let allObjects = []; this.bindListeners({ addDomainObject: PolicyActions.addDomainObject, }); } addDomainObject(payload) { console.log("**addDomainObject.."); console.log(this); } }
module.exports = alt.createStore(PolicyStore, "PolicyStore");
When I trigger the action to add domain object, Why this refer to Alt, not the PolicyStore?
I have to use this.getInstance() to get policyStore's reference?
Is there any advise or suggestion?
Best Regards.
Andy.hu
When I trigger the action to add domain object, why this refer to Alt, not the PolicyStore?
Below is my code.
app.js
var Alt = require('alt'); //console.log(Alt) var alt = new Alt();
module.exports = alt;
my Action: import alt from '../app'; class PolicyActions {
addDomainObject(modelName, objectCode, scopeObject) {
var payload = {};
payload.modelName = modelName;
payload.objectCode = objectCode;
payload.scopeObject = scopeObject;
this.dispatch(payload); }
}
module.exports = alt.createActions(PolicyActions);
myStore
import alt from '../app'; class PolicyStore {
constructor() { let policy = {}; let allObjects = [];
this.bindListeners({
addDomainObject: PolicyActions.addDomainObject,
}); }
addDomainObject(payload) {
console.log("**addDomainObject..");
console.log(this);
} }
module.exports = alt.createStore(PolicyStore, "PolicyStore");
When I trigger the action to add domain object, Why this refer to Alt, not the PolicyStore?