react-arbiter
Advanced tools
Comparing version 0.9.0 to 0.9.1
# React Arbiter Changelog | ||
## 0.9.1 | ||
- Improved `blazingStrategy` typing | ||
- Introduced `createProgressiveStrategy` for more flexibility | ||
- Updated dependencies | ||
## 0.9.0 | ||
@@ -4,0 +10,0 @@ |
@@ -1,3 +0,9 @@ | ||
import { ArbiterRecallOptions, ArbiterRecallModulesLoaded } from '../types'; | ||
import { ArbiterRecallOptions, ArbiterRecallModulesLoaded, ArbiterRecallStrategy } from '../types'; | ||
/** | ||
* This strategy is dependent on the async parameter. If false it will start rendering when | ||
* everything has been received, otherwise it will start rendering when the metadata has been | ||
* received. In any case it will evaluate modules as fast as possible. | ||
*/ | ||
export declare function createProgressiveStrategy<TApi>(async: boolean): ArbiterRecallStrategy<TApi>; | ||
/** | ||
* This strategy starts rendering when the modules metadata has been received. | ||
@@ -7,3 +13,3 @@ * Evaluates the modules once available without waiting for all modules to be | ||
*/ | ||
export declare function blazingStrategy<TApi>(options: ArbiterRecallOptions<TApi>, cb: ArbiterRecallModulesLoaded<TApi>): Promise<import("../types").ArbiterModuleMetadata[]>; | ||
export declare function blazingStrategy<TApi>(options: ArbiterRecallOptions<TApi>, cb: ArbiterRecallModulesLoaded<TApi>): Promise<void>; | ||
/** | ||
@@ -10,0 +16,0 @@ * The async strategy picked when no strategy is declared and async is set to |
@@ -14,2 +14,33 @@ "use strict"; | ||
/** | ||
* This strategy is dependent on the async parameter. If false it will start rendering when | ||
* everything has been received, otherwise it will start rendering when the metadata has been | ||
* received. In any case it will evaluate modules as fast as possible. | ||
*/ | ||
function createProgressiveStrategy(async) { | ||
return (options, cb) => { | ||
const { fetchModules, fetchDependency, dependencies, getDependencies, cache, createApi, modules = [] } = options; | ||
const getDep = utils_1.getDependencyResolver(dependencies, getDependencies); | ||
const loader = utils_1.loadModulesMetadata(fetchModules, cache); | ||
const allModules = utils_1.createModules(createApi, [...modules]); | ||
if (async && allModules.length > 0) { | ||
cb(undefined, allModules); | ||
} | ||
const followUp = loader.then(metadata => metadata.map(m => utils_1.loadModule(m, getDep, fetchDependency).then(mod => { | ||
const available = modules.filter(m => m.name === mod.name).length === 0; | ||
metadata.pop(); | ||
if (available) { | ||
allModules.push(utils_1.createModule(createApi, mod)); | ||
if (async) { | ||
cb(undefined, allModules); | ||
} | ||
} | ||
if (!async && metadata.length === 0) { | ||
cb(undefined, allModules); | ||
} | ||
}))); | ||
return async ? loader.then() : followUp.then(); | ||
}; | ||
} | ||
exports.createProgressiveStrategy = createProgressiveStrategy; | ||
/** | ||
* This strategy starts rendering when the modules metadata has been received. | ||
@@ -20,17 +51,4 @@ * Evaluates the modules once available without waiting for all modules to be | ||
function blazingStrategy(options, cb) { | ||
const { fetchModules, fetchDependency, dependencies, getDependencies, cache, createApi, modules = [] } = options; | ||
const getDep = utils_1.getDependencyResolver(dependencies, getDependencies); | ||
const loader = utils_1.loadModulesMetadata(fetchModules, cache); | ||
const allModules = utils_1.createModules(createApi, [...modules]); | ||
if (allModules.length > 0) { | ||
cb(undefined, allModules); | ||
} | ||
loader.then(metadata => metadata.map(m => utils_1.loadModule(m, getDep, fetchDependency).then(mod => { | ||
const available = modules.filter(m => m.name === mod.name).length === 0; | ||
if (available) { | ||
allModules.push(utils_1.createModule(createApi, mod)); | ||
cb(undefined, allModules); | ||
} | ||
}))); | ||
return loader; | ||
const strategy = createProgressiveStrategy(true); | ||
return strategy(options, cb); | ||
} | ||
@@ -37,0 +55,0 @@ exports.blazingStrategy = blazingStrategy; |
{ | ||
"name": "react-arbiter", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "Recall all your modules to extend your SPA dynamically at runtime.", | ||
@@ -37,10 +37,10 @@ "main": "dist/index.js", | ||
"@types/enzyme-adapter-react-16": "^1.0.5", | ||
"@types/jest": "^24.0.15", | ||
"@types/react": "^16.8.23", | ||
"@types/react-dom": "^16.8.5", | ||
"@types/jest": "^24.0.18", | ||
"@types/react": "^16.9.2", | ||
"@types/react-dom": "^16.9.0", | ||
"enzyme": "^3.10.0", | ||
"enzyme-adapter-react-16": "^1.14.0", | ||
"enzyme-to-json": "^3.4.0", | ||
"jest": "^24.8.0", | ||
"jest-cli": "^24.8.0", | ||
"jest": "^24.9.0", | ||
"jest-cli": "^24.9.0", | ||
"prettier": "^1.18.2", | ||
@@ -50,3 +50,3 @@ "react": "^16.9.0", | ||
"ts-jest": "^24.0.2", | ||
"tslint": "^5.18.0", | ||
"tslint": "^5.19.0", | ||
"tslint-config-prettier": "^1.18.0", | ||
@@ -53,0 +53,0 @@ "tslint-plugin-prettier": "^2.0.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83438
1199