Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Observable array should be concat-spreadable #984

Closed
7 tasks done
Zzzen opened this issue May 10, 2017 · 3 comments
Closed
7 tasks done

Observable array should be concat-spreadable #984

Zzzen opened this issue May 10, 2017 · 3 comments

Comments

@Zzzen
Copy link

Zzzen commented May 10, 2017

I have a*:

  1. Issue:
  • Provide error messages including stacktrace
  • Provide as much relevant code, or, preferrably create a reproduction based on this JSFiddle:
  • Did you check this issue wasn't filed before?
  • Elaborate on your issue. What behavior did you expect?
  • State the versions of MobX and relevant libraries. Which browser / node / ... version?
  • Are you willing to (attempt) a PR yourself?

MobX version: 3.1.7
Code:

    var a2 = mobx.observable([3, 4])
    var result = [1, 2].concat(a2)

I expect result to be [1, 2, 3, 4]. But it is [1, 2, ObservableArray]

Zzzen added a commit to Zzzen/mobx that referenced this issue May 10, 2017
@spion
Copy link

spion commented May 11, 2017

Unfortunately this will cause unexpected behaviour in older browsers (see #806)

@mweststrate
Copy link
Member

This is indeed a known limitation until proxies are fully supported. Use a2.slice() instead. Also see the docs.

@vantuan88291
Copy link

0

another way to concat array in mobx:

const arr = [...self.data, ...result.data.data.customers]
self.data.replace(arr)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants