Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mobx-keystone-asyncstore

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-keystone-asyncstore - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

2

dist/AsyncStore.d.ts

@@ -167,4 +167,4 @@ import { AnyModel, ModelClass, ModelProps, _Model } from "mobx-keystone";

getMany(id: string[]): T[];
getAll(): T[];
getAll(force?: boolean): T[];
createAsyncContainer(id: string, add?: boolean): T;
}

@@ -38,2 +38,21 @@ "use strict";

this.hasAll = false;
this.fetchQueueExecutor = (shouldFetch) => __awaiter(this, void 0, void 0, function* () {
if (shouldFetch) {
// Prioratize fetching all
const fetchAllIndex = this.fetchQueue.indexOf("*");
if (fetchAllIndex !== -1) {
this.spliceFetchQueue(fetchAllIndex, 1);
yield this.fetchAll();
}
else {
const idsToFetch = this.spliceFetchQueue(0, batchSize);
if (idsToFetch.length === 1) {
yield this.fetchOne(idsToFetch[0]);
}
else {
yield this.fetchMany(idsToFetch);
}
}
}
});
this.fetchOne = mobx_keystone_1._async(function* (id) {

@@ -110,26 +129,7 @@ if (!fetchOne && !fetchMany) {

onInit() {
const dispose = mobx_1.reaction(() => !this.isPending && this.fetchQueue.length > 0, (shouldFetch) => __awaiter(this, void 0, void 0, function* () {
if (shouldFetch) {
// Prioratize fetching all
const fetchAllIndex = this.fetchQueue.indexOf("*");
if (fetchAllIndex !== -1) {
this.spliceFetchQueue(fetchAllIndex, 1);
yield this.fetchAll();
}
else {
const idsToFetch = this.spliceFetchQueue(0, batchSize);
if (idsToFetch.length === 1) {
yield this.fetchOne(idsToFetch[0]);
}
else {
yield this.fetchMany(idsToFetch);
}
}
}
}), {
const dispose = mobx_1.reaction(() => !this.isPending && this.fetchQueue.length > 0, this.fetchQueueExecutor, {
fireImmediately: true,
scheduler: (run) => {
return setTimeout(run, throttle);
},
scheduler: this.fetchQueueScheduler,
});
/* istanbul ignore next */
return () => {

@@ -139,2 +139,5 @@ dispose();

}
fetchQueueScheduler(run) {
setTimeout(run, throttle);
}
spliceFetchQueue(start, end) {

@@ -172,2 +175,3 @@ return this.fetchQueue.splice(start, end);

getMany(ids) {
const idsToFetch = [];
const cts = ids.map((id) => {

@@ -179,5 +183,10 @@ let ct = this.containers.get(id);

}
if (ct.shouldFetch) {
idsToFetch.push(id);
}
return ct;
});
this.addToFetchQueue(ids);
if (idsToFetch.length > 0) {
this.addToFetchQueue(idsToFetch);
}
return cts;

@@ -184,0 +193,0 @@ }

{
"name": "mobx-keystone-asyncstore",
"version": "0.3.0",
"version": "0.3.1",
"author": "Marcus Ekwall <marcus.ekwall@gmail.com>",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc