Move event handler assignment into method
This commit is contained in:
@@ -19,6 +19,9 @@ export default Route.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
afterModel() {
|
afterModel() {
|
||||||
return this.get('kredits').loadContributorsAndProposals();
|
return this.get('kredits').loadContributorsAndProposals()
|
||||||
|
.then(() => {
|
||||||
|
this.get('kredits').addContractEventHandlers();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -88,7 +88,11 @@ export default Service.extend({
|
|||||||
}).then(({ contributors, proposals }) => {
|
}).then(({ contributors, proposals }) => {
|
||||||
this.set('contributors', contributors);
|
this.set('contributors', contributors);
|
||||||
this.set('proposals', proposals);
|
this.set('proposals', proposals);
|
||||||
}).then(() => {
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
addContractEventHandlers() {
|
||||||
|
// Operator events
|
||||||
this.get('kredits').Operator
|
this.get('kredits').Operator
|
||||||
.on('ProposalCreated', (proposalId) => {
|
.on('ProposalCreated', (proposalId) => {
|
||||||
this.handleProposalCreated(proposalId);
|
this.handleProposalCreated(proposalId);
|
||||||
@@ -100,11 +104,11 @@ export default Service.extend({
|
|||||||
this.handleProposalExecuted(proposalId, contributorId, amount);
|
this.handleProposalExecuted(proposalId, contributorId, amount);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Token events
|
||||||
this.get('kredits').Token
|
this.get('kredits').Token
|
||||||
.on('Transfer', (from, to, value) => {
|
.on('Transfer', (from, to, value) => {
|
||||||
this.handleTransfer(from, to, value);
|
this.handleTransfer(from, to, value);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: Only assign valid attributes
|
// TODO: Only assign valid attributes
|
||||||
@@ -112,11 +116,6 @@ export default Service.extend({
|
|||||||
debug('[kredits] build', name, attributes);
|
debug('[kredits] build', name, attributes);
|
||||||
let model = getOwner(this).lookup(`model:${name}`);
|
let model = getOwner(this).lookup(`model:${name}`);
|
||||||
|
|
||||||
// coerce id to string
|
|
||||||
if (attributes.id) {
|
|
||||||
attributes.id = attributes.id.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
model.setProperties(attributes);
|
model.setProperties(attributes);
|
||||||
return model;
|
return model;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user