一点点😨!我姓陈,父母是从福建来的。
Lauren Elizabeth Tan
22

Yeah, agree with you for the DDAU part.

Once I really not to care who/where to modify the data, but the more I use Ember (along with its competitors Angular/React/…) the more I start to realize how important immutable data structure is, in other words: UI related components should not know/care where the data came from and who the data belongs to, and of course, should not mutate it.

It is hard to understand for self-taught front-end engineers, like me 😝, because they often lack of knowledges about low-level memory manipulation and management… God bless front-end fellas!

For the 2nd answers, I’m still confused, plz enlighten me. As far as I know, computed properties will get the value depends on “seeing” something changes. I have to calculate the position after each render process because it needs the DOM actually existed, right?

So, even I define it as a CP, what property I should specify for it to “seeing” changes? I mean:

export default Ember.Component.extend({
  positions: Ember.computed(/* what? */, {
    get() { return /* what? */ }
  }),
  didRender() {
    let clientRect = this.element.getBoundingClientRect()
    /* Now we can have `clientRect.top/right/bottom/left/width/height`, but how to tell `position` to recalculate itself depends on these values? */
    /* I can do `this.set('_positions', clientRect.xxx)` and let `this.positions` to watch `'_positions'`, but what's the differences than set `positions` directly here? */
  }
})

I just don’t know how to solve this problem above in a correct way, what’s your suggestions?

Show your support

Clapping shows how much you appreciated Albert Yu’s story.