adopted-ember-addons / adopted-ember-addons/ember-data-model-fragments

Change ModelFragment attributes on runtime

Abierto
#277 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
367
Forks
108
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I have a use case where I need to add new `attr()`'s to a ModelFragment on runtime.

TL;DR; It involves getting metadata from a remote API, and based on that build the model... a.k.a. dynamic attributes

I have tried unregistering and re-registering the model directly from the store:

```
store.unregister('model:any-model');
store.register('model:any-model');, ModelFragment.extend({...})
```

But that only works during *sync* application `instance-initializers` and `init()` methods (in routes, components, whatever).

If I try doing it after an *async* promise is fulfilled, ex. at `beforeModel()`, it simply doesn't work 😢

Any hint would be greatly appreciated!

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

The issue names ModelFragment, store.unregister/register, synchronous instance-initializers and init(), and asynchronous beforeModel(). Start by reproducing the registration attempt after the promise resolves and tracing those entry points; done should mean runtime-added attr() definitions are available on the model.

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

Evaluación

Stack tecnológico
typescript
Área
backend
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.