add simple mesh/group list
This commit is contained in:
parent
eb2fbf2a09
commit
930e591c44
7 changed files with 149 additions and 29 deletions
|
|
@ -23,6 +23,20 @@ gapp.broker = new class Broker {
|
|||
return Object.keys(this.topics);
|
||||
}
|
||||
|
||||
// create subscriptions for all functions in an object
|
||||
// a complement wrapObject on the subscription side
|
||||
listeners(object, root) {
|
||||
for (let [key, fn] of Object.entries(object)) {
|
||||
if (typeof fn === 'function') {
|
||||
key = root ? `${root}_${key}` : key;
|
||||
this.subscribe(key, fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// attach function to a topic
|
||||
// creates topic if new topic
|
||||
// creates a send function if new topic
|
||||
subscribe(topic, listener) {
|
||||
if (Array.isArray(topic)) {
|
||||
for (let t of topic) {
|
||||
|
|
|
|||
|
|
@ -58,8 +58,9 @@ function build(data, context) {
|
|||
func[key] = val;
|
||||
elid = elid || `_${nextid++}`;
|
||||
} else if (tov === 'object') {
|
||||
html.push(` ${key}="${val.join(' ')}"`);
|
||||
} else {
|
||||
if (val.length)
|
||||
html.push(` ${key}="${val.filter(v => v !== undefined).join(' ')}"`);
|
||||
} else if (tov !== 'undefined') {
|
||||
html.push(` ${key}="${val}"`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue