1

For example I have Payments and have User. It's Many-to-one relationship. But I don't want to have Payments as nested properties of User.

In redux I would live an ID.

//redux
const state = {
  users = [{
    id: 232,
    payments: [123]
  }]
  payments: [{
    id: 123,
    user: 232
  }]
}

or something like this. What's the way to works with references in mobx? I would like to use links so I can:

user.payment['doSomething']

1 Answer 1

0

The great thing with mobx is what you can store links in observable. All you need is init them.

const user = new User
const payment = new Payment
user.payment = payment
payment.user = user

Now you can do user.payment.value = 'newVal' Just make sure property payment inside user and property user inside payment are @observable

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.