adopted-ember-addons / adopted-ember-addons/ember-data-model-fragments
Change ModelFragment attributes on runtime
- 主要言語
- 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