Skip to content

How to make a model for array? #2240

Answered by coolsoftwaretyler
OnkelTem asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, so just to see if we're on the same page. Is this the kind of logic you want to implement? And if so, is it missing something that you need?

Or have I still misunderstood what you're trying to do?

See in CodeSandbox

import { getSnapshot, t, flow } from "mobx-state-tree";

/**
 * Sample Pet interface, just an id and a string as metadata,
 * and a generatedAt timestamp to help see how responses were ordered
 * and used.
 */
interface Pet {
  petId: number;
  additionalMetadata: string;
  generatedAt: Date;
}

/**
 * Fake API, returns a promise of Pet[].
 */
function getPets(): Promise<Pet[]> {
  return new Promise((resolve) => {
    const timestamp = new Date();
    const petArray: Pet[] =

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@OnkelTem
Comment options

@coolsoftwaretyler
Comment options

@coolsoftwaretyler
Comment options

@coolsoftwaretyler
Comment options

Answer selected by coolsoftwaretyler
@OnkelTem
Comment options

@OnkelTem
Comment options

@coolsoftwaretyler
Comment options

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