stewie1570 / leaf-validator Goto Github PK
View Code? Open in Web Editor NEWDeclarative state progression & validation for React apps.
License: MIT License
Declarative state progression & validation for React apps.
License: MIT License
A test to verify callback form of setState works properly.
Objective is to lower the package size and increase performance at the same time.
If the package consumer supports ESM then the consumer should support a higher compilation target than the default of ES3.
Diff currently builds complex objects by setting root properties to a whole complex object. Each diff should be scoped all the way to a single leaf.
leaf-validator/src/lib/Leaf.tsx
Line 74 in f22d41c
From minified to minzipped.
const [isLoading, doLoad] = useLoadingState(loadingFunction);
doLoad type definition from loadingFunction type def.
After the next release of react-scripts
you should be able to remove --env=jest-environment-jsdom-sixteen
from scripts and remove jest-environment-jsdom-sixteen
from devDependencies.
New Feature Idea 💡
For backward compatibility with persistence layer:
Leaf should use the first defined failOverLocations in the model when the location in the model is undefined.
{
...
"main": "cjs/index.js",
"module": "esm/index.js",
...
}
Validators can be async. As such, they could resolve after the component is un-mounted and cause un-mounted state change warnings/errors.
leaf-validator/src/lib/hooks/useValidationModel.ts
Lines 16 to 29 in 1f292b6
useMountedOnlyState instead of useState.
leaf-validator/src/lib/Leaf.test.tsx
Line 281 in f690e2d
Undefined location should query same as an empty string location.
The link to example diff usage that navigates to the mongo/leaf-validator example should link directly to the line that calls the diff function:
Like this:
Example
The hook already has an optional/configurable deferment of starting the loading state but there should also be an optional/configurable amount of minimum loading time.
For use with react...
Non open source projects should be able to use this.
Example from the example app:
[
{
"location": "deferredAsyncValidation",
"messages": [
"Value is required"
]
},
{
"location": "asyncValidation",
"messages": [
"\"undefined\" is not valid."
]
},
{
"location": "deferredAsyncValidation",
"messages": [
"\"undefined\" is not valid."
]
}
]
deferredAsyncValidation has two objects because there are two namespaces for those validators (deferred and not deferred).
Encourages normalization - link to Redux docs.
Encourages best practices documented by Redux (but without as much overhead since reducers are implemented declaratively).
Merge
Release (v3.6.2)
React error boundaries do not catch rejected promises. Create a component that will catch errors and unhandled rejections in its children composition.
This is testing a new instance of the component....Not necessary.
leaf-validator/src/lib/hooks/useMountedOnlyState.test.tsx
Lines 71 to 72 in 1f292b6
This is testing a whole new instance of the component that use mounted-only-state.
Same as use state but state setters turn into No Ops when the component is not mounted.
useLoadingState should use this.
omg, how embarrassing. The methods in the validation model take model shape and validation results as a parameters. It has no need for the model itself. How did I miss this?
Validation could be called multiple times before the first validation resolves. Only the latest validation results should be applied to the validation model.
Similar to https://www.npmjs.com/package/react-error-boundary but can support displaying multiple errors at the same time and does not change the child component composition.
Implementation
Documentation
Publish
leaf-validator/src/lib/hooks/useLoadingState.ts
Lines 14 to 20 in 4b569a3
This can just await the configured amount of time before setting loading to true since the operation promise is already inflight when the hook function is invoked.
Refactor to promise async composition instead of callbacks.
Merge
Release (v3.6.2)
Currently appears to process the whole object even if the root is referencing the original.
[Get & Set pure functions](#get-&-set-pure-functions)
works in VSCode but not GitHub or NPMJs.com
It would be nice to have source control & ci in one cohesive place. Plus the travis-ci badge is randomly showing failed even though its passing and it is starting to piss me off.
location
as a parameter to child render function of Leaf component.To invoke the effects just like deferred validators.
This attribute should only run the validators after some fixed amount of time after the last target value change. The validators should not be run again until they've all resolved.
Create (& export) a function that can take the current model, the original model and return a list of key-value-pairs. The keys being progressed value locations and the value being the current value for that location.
Appears related to: facebook/create-react-app#9583
Causing build failure on my mac.
Investigate
Fix
Merge
No need to publish - package build time problem only.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.