Installations
npm install mobx-keystone-asyncstore
Developer Guide
Typescript
No
Module System
CommonJS
Score
71.1
Supply Chain
97.1
Quality
75.8
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (89.71%)
JavaScript (10.29%)
validate.email 🚀
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Developer
mekwall
Download Statistics
Total Downloads
2,886
Last Day
1
Last Week
2
Last Month
26
Last Year
338
GitHub Statistics
MIT License
4 Stars
86 Commits
1 Forks
1 Watchers
2 Branches
1 Contributors
Updated on Dec 30, 2024
Bundle Size
15.10 kB
Minified
4.98 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.5.2
Package Id
mobx-keystone-asyncstore@0.5.2
Unpacked Size
47.88 kB
Size
10.38 kB
File Count
12
Total Downloads
Cumulative downloads
Total Downloads
2,886
Peer Dependencies
2
Dev Dependencies
30
mobx-keystone-asyncstore
An opinionated asynchronous store and container implementation for mobx-keystone.
⚠️WARNING: This library is under development and not yet considered stable. Use with caution as breaking changes to the API may be introduced until reaching v1.
Introduction
One of the most common challenges when implementing a store solution is how to handle asynchronous data sets. mobx-keystone-asyncstore aims to simplify this by allowing you to create powerful asynchronous stores with just a few lines of code. An mobx-keystone-asyncstore implements the most common fetch patterns and support fetch queues, fail states and time to live out of the box.
Let's look at a simple implementation of a TodoStore:
1import axios from "axios"; 2import { when } from "mobx"; 3import { model, modelAction, Model, tProp, types } from "mobx-keystone"; 4import { AsyncStore } from "mobx-keystone-asyncstore"; 5 6// Create main model 7@model("models/TodoItem") 8class TodoItem extends Model({ 9 id: tProp(types.string), 10 task: tProp(types.string), 11 done: tProp(types.boolean, false), 12}) { 13 @modelAction 14 public toggleDone() { 15 this.done = !!this.done; 16 } 17} 18 19// Create async store 20const storeName = "stores/TodoStore"; 21@model(storeName) 22class TodoStore extends AsyncStore( 23 TodoItem, 24 { 25 name: storeName, 26 // Logic to fetch one item 27 async fetchOne(id: string) { 28 const res = await axios.get(`/todos/${id}`); 29 return new TodoItem(res.data); 30 }, 31 // Logic to fetch many items 32 async fetchMany(ids: string[]) { 33 const res = await axios.get(`/todos`, { ids }); 34 return res.data.response.map((d: any) => new TodoItem(d)); 35 }, 36 // Logic to fetch all items 37 async fetchAll() { 38 const res = await axios.get(`/todos/all`); 39 return res.data.response.map((d: any) => new TodoItem(d)); 40 }, 41 }, 42 { 43 // Add additional model props for the store 44 isDirty: tProp(types.boolean, true), 45 } 46) { 47 @modelAction 48 public setDirty(isDirty = true) { 49 this.isDirty = isDirty; 50 } 51 52 // Add additional methods for the store 53 @modelAction 54 public addTodo(task: TodoItem) { 55 // Create container that will contain our task 56 const container = this.createAsyncContainer(task.id); 57 // Add task to container value 58 container.setValue(task); 59 // Add container to store 60 this.containers.set(task.id, container); 61 // Set the store as dirty 62 this.setDirty(); 63 // Let's return the container so it may be used 64 return container; 65 } 66 67 // Method to save all our todos 68 async saveToDb() { 69 if (this.isDirty) { 70 const res = await axios.post(`/todos`, this.values); 71 if (res.status === 200) { 72 this.setDirty(false); 73 } 74 } 75 } 76} 77 78// Create store instance 79const todoStore = new TodoStore({}); 80 81// Ask the store to return container with id 'foo' 82const container = todoStore.getOne("foo"); 83 84// Wait for the container to be ready to be consumed 85when( 86 () => container.isReady, 87 () => { 88 const todo = container.value; 89 // todo is an instance of TodoItem 90 todo.toggleDone(); 91 } 92); 93 94// Add a new todo to the store 95todoStore.addTodo( 96 new TodoItem({ 97 id: "bar", 98 task: "Do this thing as well", 99 }) 100); 101 102// Use our custom save method 103todoStore.saveToDb();

No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:7: update your workflow using https://app.stepsecurity.io/secureworkflow/mekwall/mobx-keystone-asyncstore/main.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/mekwall/mobx-keystone-asyncstore/main.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/mekwall/mobx-keystone-asyncstore/main.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/mekwall/mobx-keystone-asyncstore/main.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/mekwall/mobx-keystone-asyncstore/main.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/mekwall/mobx-keystone-asyncstore/main.yml/master?enable=pin
- Info: 0 out of 1 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 5 third-party GitHubAction dependencies pinned
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
63 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-h5c3-5r3r-rr8q
- Warn: Project is vulnerable to: GHSA-rmvr-2pp2-xj38
- Warn: Project is vulnerable to: GHSA-xx4v-prfh-6cgc
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-4r62-v4vq-hr96
- Warn: Project is vulnerable to: GHSA-5v2h-r2cx-5xgj
- Warn: Project is vulnerable to: GHSA-rrrm-qjm4-v8hf
- Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-w7rc-rwvf-8q5r
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-px4h-xg32-q955
- Warn: Project is vulnerable to: GHSA-pw54-mh39-w3hc
- Warn: Project is vulnerable to: GHSA-xgh6-85xh-479p
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-r2j6-p67h-q639
- Warn: Project is vulnerable to: GHSA-x2pg-mjhr-2m5x
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-44c6-4v22-4mhx
- Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch
- Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
- Warn: Project is vulnerable to: GHSA-38fc-wpqx-33j7
- Warn: Project is vulnerable to: GHSA-cf4h-3jhx-xvhq
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
2.5
/10
Last Scanned on 2025-03-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More