Observer pattern
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
Línea de trabajo
Comienza con switch.py y la implementación de Widget/YDoc mostrada en la issue, y después revisa cómo psygnal y traitlets representan los atributos observados. Determina si un diseño de observadores viable cubre la entrada de valor de YMap y las estructuras YDoc anidadas. La tarea se considerará terminada cuando se haya acordado el alcance de la implementación y exista un enfoque claro para observar estas estructuras.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
In https://github.com/jupyter-widgets/ipywidgets/issues/3293#issuecomment-1433848240 @tlambert03 mentioned psygnal, that could be used to implement the equivalent of traitlets.
I think it is a good idea, but I'm not sure how it could fit here. For instance, take the Switch model, currently implemented as:
from .ypywidgets import Widget
class Switch(Widget):
def __init__(self, value: bool = False, open_comm: bool = True) -> None:
super().__init__(name="switch", open_comm=open_comm)
self.yvalue = self.ydoc.get_map("value")
self._set(value)
def _set(self, value: bool) -> None:
with self.ydoc.begin_transaction() as t:
self.yvalue.set(t, "value", value)
@property
def value(self) -> bool:
return self.yvalue["value"]
@value.setter
def value(self, value: bool):
if value == self.value:
return
self._set(value)
def toggle(self):
self.value = not self.value
Its YDoc consists of a YMap named value, with a single entry in it, also named value, which contains the boolean value of the switch. Here the observer pattern is manually implemented using a getter and a setter function for the value attribute.
If we were to use psygnal, we would need a way to point to the YDoc's structure (self.yvalue and value entry in it) from the psygnal's attribute.
I think that's the reason why traitlets use Python's descriptor protocol, which allows to get the name of an attribute at runtime.
Also, I'm not sure how we could connect nested YDoc structures (e.g. a YMap can contain other Y structures), but I don't think it was possible with traitlets anyway, so that would be an improvement.
- Lenguaje dominante
- Python
- Estrellas
- 16
- Forks
- 7
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de QuantStack/ypywidgets
-
Move to another org Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
QuantStack/ypywidgets#12 · 1 comentario ·
-
Y server code duplication Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
QuantStack/ypywidgets#2 ·
Todos los issues de QuantStack/ypywidgets
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
zostera/django-bootstrap4#894 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
use-agent-os/agent-os#3276 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
NousResearch/hermes-agent#117848 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
zilliztech/memsearch#759 ·