{"id":15348109,"url":"https://github.com/mintsweet/mst-advanced","last_synced_at":"2025-06-21T03:34:41.118Z","repository":{"id":37730024,"uuid":"475790246","full_name":"mintsweet/mst-advanced","owner":"mintsweet","description":"⚙️ advanced model for mst","archived":false,"fork":false,"pushed_at":"2022-11-02T12:38:22.000Z","size":1379,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T23:36:10.874Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mintsweet.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-30T08:35:28.000Z","updated_at":"2023-04-26T12:39:22.000Z","dependencies_parsed_at":"2023-01-21T05:16:53.799Z","dependency_job_id":null,"html_url":"https://github.com/mintsweet/mst-advanced","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintsweet%2Fmst-advanced","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintsweet%2Fmst-advanced/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintsweet%2Fmst-advanced/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintsweet%2Fmst-advanced/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mintsweet","download_url":"https://codeload.github.com/mintsweet/mst-advanced/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247334039,"owners_count":20922130,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T11:44:53.038Z","updated_at":"2025-04-05T12:22:00.186Z","avatar_url":"https://github.com/mintsweet.png","language":"TypeScript","readme":"# mst-advanced\n\n\u003e advanced model for mst\n\n## Installation\n\n```\n$ yarn add react react-dom mobx mobx-state-tree lodash\n$ yarn add mst-advanced\n```\n\n## Usage\n\n### Create Query Model\n\n```javascript\nimport { types } from 'mobx-state-tree';\nimport { createQueryModel } from 'mst-advanced';\n\nexport const Store = createQueryModel({\n  Model: types.model({\n    name: types.maybeNull(types.string);\n  }),\n  onQuery: (signal) =\u003e apiCall('/xxx/xxx', { signal }),\n  onResult: (t, res) =\u003e {\n    t.data = res;\n  },\n});\n```\n\n### Create List Model\n\n```javascript\nimport { types } from 'mobx-state-tree';\nimport { createListModel } from 'mst-advanced';\n\nconst Item = types.model({\n  name: types.string;\n});\n\nexport const Store = createListModel({\n  Item,\n  onQuery: (signal, params) =\u003e apiCall('/xxx/xxx', { signal, params }),\n  onResult: (i:) =\u003e ({\n    name: i.name,\n  }),\n});\n```\n\n### Use in react page\n\n```javascript\nimport { observer } from 'mobx-react-lite';\nimport { useQuery } from 'mst-advanced';\n\nimport { Store } from '../models'; // query model or list model\n\nexport default function Page() {\n  const { loading, error, data } = useQuery(Model1Store, { page: 1, pageSize: 10 });\n\n  if (loading) {\n    return \u003cdiv\u003eLoading...\u003c/div\u003e;\n  }\n\n  if (error) {\n    return \u003cdiv\u003eSomething Error.\u003c/div\u003e;\n  }\n\n  return \u003cdiv\u003epage\u003c/div\u003e;\n}\n```\n\n## License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmintsweet%2Fmst-advanced","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmintsweet%2Fmst-advanced","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmintsweet%2Fmst-advanced/lists"}