Array of References #301
Unanswered
mashaalmemon
asked this question in
Q&A
Replies: 1 comment 1 reply
-
@model("NTodo")
export class NTodo
extends ExtendedModel(BaseNModel, {
userListRefs: prop<Ref<NUser>[]>() // just this should be enough, might want to add a default `() => []`
})
implements Partial<ITodo>
{
// this method is optional
@computed
public get userList(): IUser[] {
// return all refs that are not broken
// if we use .current we risk this method to throw if one of the refs is broken (might be
// what you want though)
return this.userListRefs.map(r => r.maybeCurrent).filter(r => r !== undefined)
}
}
I'm not quite sure what you mean, all arrays in mobx-keystone are observable arrays, but an array being observable has nothing to do with references 🤷♂️ |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What is the proper way to store an array of references? For my references I setup something like this:
Does something like this equate to an observable array, or do I need to do things differently?
Beta Was this translation helpful? Give feedback.
All reactions