Skip to content

[Question] large array element replace/update issue with observable object #3965

Answered by yanzou
yanzou asked this question in Q&A
Discussion options

You must be logged in to vote

I finially relized it possibly not just the oberserable array itself but with other computed properties watching the data:

  • If I run the simplified code (as my 1st comment) which dose not "connect" to UI layer, the operation is fast.
  • but in the real code, MyClass is much much complicated, it has some other computed props oberserving the array, something like:
class MyClass {
  ...
  @action 
  public updateMyElems = (arr) => {
    this.data.myArray = arr;
  } 

  // some computed flag depends on `myArray`
  @computed
  public get isOneOfElementOk() {
       return this.data.myArray.find(ele  => ele.XXX.yyy.zzz === 'something' )
  }
  ....
}

According to mobx doc, the action internally al…

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@mweststrate
Comment options

@yanzou
Comment options

Comment options

You must be logged in to vote
1 reply
@yanzou
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by yanzou
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants