Skip to content

Commit

Permalink
feat (compute): subscribe var update
Browse files Browse the repository at this point in the history
  • Loading branch information
santanche committed Jan 31, 2022
1 parent 254923d commit 89fec10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ class RuleDCCCellNeighbor extends RuleDCCTransition {

notify (topic, message) {
switch (topic.toLowerCase()) {
case 'probability': this.probability = message.value; break
case 'probability':
this.probability =
(message.value != null) ? message.value : message.body;
break
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/adonisjs/public/dccs/components/control/dcc-compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,15 @@ class DCCCompute extends DCCBase {
this.setAttribute('dependency', newValue)
}

notify (topic, message) {
if (topic.toLowerCase() == 'update')
async notify (topic, message) {
const tp = topic.toLowerCase()
if (tp == 'update')
this.update()
else if (tp.startsWith('var/')) {
await this._request('var/set/' + tp.substring(4).replace(/\./g, '/'),
message.value)
this.update()
}
}

async update () {
Expand Down

0 comments on commit 89fec10

Please sign in to comment.