def __init__(self, keys_value, lookup_value_function): self.keys_value = keys_value self.lookup_value_function = lookup_value_function self.keys_listener = listen(self.keys_value, lambda: self.on_keys_change()) self.keys_up_to_date = False self.tracker = ChangeTracker()
def add_input(self,name,value): assert self.inside_with if self.debug: print 'master: send new value %s, %s'%(name,value()) self.conn.send((NEW_VALUE,(name,value()))) def changed(): if self.debug: print 'master: send set value %s, %s'%(name,value()) self.conn.send((SET_VALUE,(name,value()))) self.listeners.append(listen(value,changed))
def add_output(self,name,value): assert name not in self.outputs self.outputs[name] = value if self.debug: print '%s: send new value %s'%(self.side,name) val = None if value.dirty() else value() self.conn.send((NEW_VALUE,(name,val))) def push(): val = None if value.dirty() else value() if self.debug: print '%s: send push %s, %s'%(self.side,name,val) self.conn.send((SET_VALUE,(name,val))) self.listeners.append(listen(value,push))
def track(self, name, value_ref): self._refs[name] = value_ref self._listeners[name] = listen(value_ref, lambda: self._on_change(name))
def __init__(self, source_value, vtype): self.source_value = source_value self._up_to_date = False self.vtype = vtype self.listener = listen(self.source_value, self.refresh)