[CONTEXT]: provided values are handed over on connect only, consumers do not follow later provider updates

Abierto
#175 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Activo
Stack tecnológico
javascript
Área
frontend

Línea de trabajo

Read BaseElement.update() and verifyProvidedProperties() to assess the proposed update hook and its subtree walk; compare the behavior with the context example in examples/showcase/ and the current context documentation. The issue needs a maintainer decision between documenting connect-time values and updating consumers after provider changes; done means that decision is reflected consistently in the implementation or docs, showcase, and treatment of manual requestContext() callbacks.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

question

Observation

A provider lists a plain value in provideProperties():

class Provider extends TemplateElement {
    properties() {
        return { theme: 'light' };
    }
    provideProperties() {
        return { theme: this.theme };
    }
}

class Consumer extends TemplateElement {
    injectProperties() {
        return { theme: '' };
    }
}

The consumer gets light when it connects. When the provider sets this.theme = 'dark' later, the consumer keeps light. A Store in provideProperties() behaves differently: it is handed over by reference, the consumer subscribes to it, so changes in the store render the consumer.

The context section of examples/showcase/ (#171) shows both behaviours side by side.

Cause

verifyProvidedProperties() replays missed requests and compares customChild[key] !== providedProperties[key], but it only runs in connectedCallback() (both branches). Nothing runs it after a provider update.

Options

  1. Document it: a provided value is handed over when the consumer connects, values that change are provided as a Store. No code.
  2. Run this.verifyProvidedProperties() at the end of BaseElement.update(). Three lines, consumers then follow every provided value. Costs a subtree walk (getAllComposedElementChildren) on every render of an element that provides something, and manual requestContext() callbacks still fire once only, which should be stated either way.

The docs currently say the injected value "will be just there at some point", which does not decide this. A maintainer decision, the showcase and the docs follow it.

Lenguaje dominante
JavaScript
Estrellas
30
Forks
5
Merge medio
1 h 57 min
PR fusionados (30 d)
10

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de webtides/element-js

Todos los issues de webtides/element-js

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.