secundant / reformed Goto Github PK
View Code? Open in Web Editor NEWForms is business logic
License: MIT License
Forms is business logic
License: MIT License
Basic implementation of static field factory, it must support disabled
and defaultValue
params to begin with.
const fieldA = createField(); // Field<unknown>
const fieldB = createField({ defaultValue: 10 });
const fieldC = createField({
defaultValue: 10,
disabled: $notAuthorized
});
sample({
clock: loggedIn,
target: fieldA.reset
});
const fields = combineFields({
fields: {
name: createField({ defaultValue: '' }),
age: createField({ defaultValue: 0 })
}
});
const nested = combineFields({
fields: {
a: createField({ defaultValue: 'foo' as const }),
b: combineFields({
fields: {
c: combineFields({
fields: {
d: createField({ defaultValue: 'bar' as const })
}
})
}
})
}
});
sample({
clock: buttonClicked,
source: $external,
fn: external => ({ b: { c: { d: external } } }),
target: nested.change
});
Proposal:
const formA = createForm({
fields: {},
// ...
submit: () => fetch()
});
const formB = createForm({
submit: {
mapParams: fields => ({ foo: 'bar', ...fields }),
fn: fetchFx
}
});
const formC = createForm({
submit: {
source: { foo: $foo },
mapParams: (fields, fromSource) => ({ ...fromSource, ...fields }),
fn: fetchFx
}
});
formC.$submitStatus; // Store<'initial' | 'pending' | 'done' | 'fail'>
formC.$succeeded; // Store<boolean>
formC.submitted.success; // Event<?>
formC.submitted.failure; // Event<?>
formC.submitted.finally; // Event<?>
Effect
change
, blur
, submit
Field
can contain multiple validation modes at same timeCombinedField
- only submit?DynamicField
- implement API (maybe will be different issue)combined.$modified
- should we compute it from children without any conditions?
$modified
in Field
is staying true
until field will be resetcombineFields
const form = createForm({
fields: { name: createField(), ... },
submit: ???
});
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.