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

Change ModelFragment attributes on runtime

オープン
#277 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
367
フォーク
108
PR マージ指標
30日以内にマージされた PR はありません

説明

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!

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
backend
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。